Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Comma in a Diesel String

1 REPLY 1
Reply
Message 1 of 2
Anonymous
315 Views, 1 Reply

Comma in a Diesel String

I am trying to get a DIESEL menu macro working. I need a different macro to run based on the value of useri1.

Generally all my DIESEL logic works with simple code:
^C^C$M=$(if,$(=,$(getvar,useri1),3),"**CODE_FOR_3**",$(if,$(or,$(=,$(getvar,useri1),1),$(=,$(getvar,useri1),2)),"**CODE_FOR_1_&_2**"))^C^C

Also my actual code for useri1=1 or useri1=2 works without DIESEL:
^C^CERASE W 10.610,7.8923 0.4490,11.3923;;^C^C

However, it doesn't work when I put that code into the DIESEL macro (not forgetting that I need quotes):
^C^C$M=$(if,$(=,$(getvar,useri1),3),"**CODE_FOR_3**",$(if,$(or,$(=,$(getvar,useri1),1),$(=,$(getvar,useri1),2)),"ERASE W 10.610,7.8923 0.4490,11.3923;;"))^C^C

The comma seems to terminate the DIESEL output after the first comma it finds in the code string. I thought that DIESEL was supposed to allow commas as part of a string as long as they were contained in quotes. My code with commas is contained in quotes, yet the macro that AutoCAD sees is something like this:
^C^CERASE W 10.610^C^C

Please do not get into picky comments about what I'm actually trying to do. Erasing a windowed box is only an example that demonstrates my comma problem. Any examples of other ways to accomplish this without using commas, or a fix to my syntax that gets my commas working is what I'm looking for. I'm in LT so AutoLISP or VBA are not options.

Using AutoCAD LT 2010 on Windows XP SP3, if that helps.

Thanks
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

I SOLVED IT!!!

It had to do with embedded IF statements.

The 2nd IF was embedded in the 1st IF. So the 2nd IF used the quotes that I had supplied, while the 1st IF was left with no quotes around it. So the 1st IF interpreted commas from the 2nd IF as extra parameters. All I had to do was add quotes inside my code section:
^C^C$M=$(if,$(=,$(getvar,useri1),3),"**CODE_FOR_3**",$(if,$(or,$(=,$(getvar,useri1),1),$(=,$(getvar,useri1),2)),"{color:#ff0000}""{color}ERASE W 10.610,7.8923 0.4490,11.3923;;{color:#ff0000}""{color}"))^C^C

Double quotes escape to a single quote. The more embedded code you have with commas the more quotes will need to be added. I wonder if it takes 4 quotes to embed a single quote in a 3 deep embedded if statement.

Sorry if this makes no sence to anyone, but it makes sence to me.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report