discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] Problem passing in strings to openscad from dos prompt

M
MichaelAtOz
Tue, Mar 29, 2016 10:34 PM

Rule 1. Backslash is the escape character; always escape quotes; only escape
backslashes if they precede a quote.

-D "val2="text""

You only need to include a semi-colon if you have multiple statements in the
one -D argument.

-D "val2="text"; val1=[10,20]"


Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/Problem-passing-in-strings-to-openscad-from-dos-prompt-tp16799p16804.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Rule 1. Backslash is the escape character; always escape quotes; only escape backslashes if they precede a quote. -D "val2=\"text\"" You only need to include a semi-colon if you have multiple statements in the one -D argument. -D "val2=\"text\"; val1=[10,20]" ----- Admin - PM me if you need anything, or if I've done something stupid... Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/Problem-passing-in-strings-to-openscad-from-dos-prompt-tp16799p16804.html Sent from the OpenSCAD mailing list archive at Nabble.com.
ST
Shaporev, Timur
Wed, Mar 30, 2016 7:10 AM

Forget it.
This is UNIX rule, not DOS/Wondows.


From: Discuss [discuss-bounces@lists.openscad.org] on behalf of MichaelAtOz [oz.at.michael@gmail.com]
Sent: 30 March 2016 01:34
To: discuss@lists.openscad.org
Subject: Re: [OpenSCAD] Problem passing in strings to openscad from dos prompt

Rule 1. Backslash is the escape character; always escape quotes; only escape
backslashes if they precede a quote.

-D "val2="text""

You only need to include a semi-colon if you have multiple statements in the
one -D argument.

-D "val2="text"; val1=[10,20]"


Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/Problem-passing-in-strings-to-openscad-from-dos-prompt-tp16799p16804.html
Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Forget it. This is UNIX rule, not DOS/Wondows. ________________________________________ From: Discuss [discuss-bounces@lists.openscad.org] on behalf of MichaelAtOz [oz.at.michael@gmail.com] Sent: 30 March 2016 01:34 To: discuss@lists.openscad.org Subject: Re: [OpenSCAD] Problem passing in strings to openscad from dos prompt Rule 1. Backslash is the escape character; always escape quotes; only escape backslashes if they precede a quote. -D "val2=\"text\"" You only need to include a semi-colon if you have multiple statements in the one -D argument. -D "val2=\"text\"; val1=[10,20]" ----- Admin - PM me if you need anything, or if I've done something stupid... Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/Problem-passing-in-strings-to-openscad-from-dos-prompt-tp16799p16804.html Sent from the OpenSCAD mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list Discuss@lists.openscad.org http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
M
mmaggio
Wed, Mar 30, 2016 2:15 PM

@MichaelAtOz you are a saint!

openscad -o Out.stl -D* "p="string"" *String_test.scad

result =

ECHO: "string"
Current top level object is empty. <-- This is correct. The test was just an
echo statment.

Thanks for fixing my implementation problem, any chance you could elaborate
a bit about why the backslashes before the quotes?
-Matt

--
View this message in context: http://forum.openscad.org/Problem-passing-in-strings-to-openscad-from-dos-prompt-tp16799p16819.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

@MichaelAtOz you are a saint! openscad -o Out.stl -D* "p=\"string\"" *String_test.scad result = ECHO: "string" Current top level object is empty. <-- This is correct. The test was just an echo statment. Thanks for fixing my implementation problem, any chance you could elaborate a bit about why the backslashes before the quotes? -Matt -- View this message in context: http://forum.openscad.org/Problem-passing-in-strings-to-openscad-from-dos-prompt-tp16799p16819.html Sent from the OpenSCAD mailing list archive at Nabble.com.
M
MichaelAtOz
Wed, Mar 30, 2016 11:36 PM

mmaggio wrote

any chance you could elaborate a bit about why the backslashes before the
quotes?

The backslash is an  escape character
https://en.wikipedia.org/wiki/Escape_character  within a double quoted
string, so /" means treat the following character as a character rather than
as a string delimiter. If you actually wanted a backslash in a quoted string
would would need "a single backslash is //". It can also be used for other
special characters.

This area can get quite complicated, see  here
http://stackoverflow.com/questions/562038/escaping-double-quotes-in-batch-script
for lots of info.

I did lots of testing with OpenSCAD command line, and found this solution to
be best.


Admin - PM me if you need anything, or if I've done something stupid...

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

The TPP is no simple “trade agreement.”  Fight it! http://www.ourfairdeal.org/  time is running out!

View this message in context: http://forum.openscad.org/Problem-passing-in-strings-to-openscad-from-dos-prompt-tp16799p16834.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

mmaggio wrote > any chance you could elaborate a bit about why the backslashes before the > quotes? The backslash is an escape character <https://en.wikipedia.org/wiki/Escape_character> within a double quoted string, so /" means treat the following character as a character rather than as a string delimiter. If you actually wanted a backslash in a quoted string would would need "a single backslash is //". It can also be used for other special characters. This area can get quite complicated, see here <http://stackoverflow.com/questions/562038/escaping-double-quotes-in-batch-script> for lots of info. I did lots of testing with OpenSCAD command line, and found this solution to be best. ----- Admin - PM me if you need anything, or if I've done something stupid... Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out! -- View this message in context: http://forum.openscad.org/Problem-passing-in-strings-to-openscad-from-dos-prompt-tp16799p16834.html Sent from the OpenSCAD mailing list archive at Nabble.com.