CyberSlug 6 Posted October 17, 2004 I get a message box saying The value of foo is and nothing else... Shouldn't it also print 42 ???Opt("ExpandVarStrings", 1) $foo = 42 $example = "The value of foo is $foo" Msgbox(4096,"", $example) Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Share this post Link to post Share on other sites
Valik 478 Posted October 17, 2004 Not only does this not display the data contained in $foo, also, if you add some text to the end of the string like this:$example = "The value of foo is $foo blah blah blah"All you will get is:The value of foo isWhich obviously has everything after the variable truncated. Share this post Link to post Share on other sites
SlimShady 1 Posted October 17, 2004 Just like environment variables, you have to add the special char also at the end. If you want to use the variable $foo, use it like this $foo$. I adjusted your example: Opt("ExpandVarStrings", 1) $foo = 42 $example = "The value of foo is $foo$" Msgbox(4096,"", $example) Share this post Link to post Share on other sites
Jos 2,164 Posted October 17, 2004 Just like environment variables, you have to add the special char also at the end.If you want to use the variable $foo, use it like this $foo$.I adjusted your example:Opt("ExpandVarStrings", 1) $foo = 42 $example = "The value of foo is $foo$" Msgbox(4096,"", $example)<{POST_SNAPBACK}>Correct, but shouldn't this also work ?Opt ("ExpandVarStrings", 1) $foo = 42 $example = "The value of $foo is $foo$" MsgBox(4096, "", $example) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
Valik 478 Posted October 17, 2004 The help file does not describe the usage like that."The value of var1 is $var1".In my opinion, requiring a trailing $ removes most of the usefulness of this feature since it still requires manual editing of the variable to get the syntax correct. If you have to manually edit the variable, then why not just add the concatenation operator and be done with it?JdeB is right. If it does require both leading/trailing $, then it should not be necessary to use $$ to escape $'s since the word needs to have both before it is a variable. That means "The value of $foo is $foo$" should print correctly.However, in the end, I don't really care how it works, I guess; I don't intend to use this feature as it makes code slightly more vague to read. Share this post Link to post Share on other sites
MHz 80 Posted October 17, 2004 Opt("ExpandVarStrings", 1) $foo = 42 $example = 'The value of $$foo is $foo$' Msgbox(4096,"", $example) This outputs 'The value of $foo is 42' Just got to have lots of $$$$ ? Share this post Link to post Share on other sites
CyberSlug 6 Posted October 17, 2004 (edited) In the end it doesn't work yet EDIT: Okay, MHz's method works, but the documentation is wrong then. And the truncation thing that Valik pointed out is a bug.I really would like to use this feature in AutoBuilder when doing code generation:'GuiCreate("MyGUI", ' & $w & ", " & $h & ",(@DesktopWidth-" & $w & ")/2, (@DesktopHeight-" & $h & ")/2 , 0x04CF0000)"versus'GuiCreate("MyGUI", $w , $h ,(@DesktopWidth - $w )/2, (@DesktopHeight - $h )/2 , 0x04CF0000)' Edited October 17, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Share this post Link to post Share on other sites
Jos 2,164 Posted October 17, 2004 In the end it doesn't work yet I really would like to use this feature in AutoBuilder when doing code generation:'GuiCreate("MyGUI", ' & $w & ", " & $h & ",(@DesktopWidth-" & $w & ")/2, (@DesktopHeight-" & $h & ")/2 , 0x04CF0000)"versus'GuiCreate("MyGUI", $w , $h ,(@DesktopWidth - $w )/2, (@DesktopHeight - $h )/2 , 0x04CF0000)'<{POST_SNAPBACK}>CyberSlug,I think it should be:'GuiCreate("MyGUI", $w$ , $h$ ,(@DesktopWidth - $w$ )/2, (@DesktopHeight - $h$ )/2 , 0x04CF0000)' SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
CyberSlug 6 Posted October 17, 2004 (edited) Actually, here's what I want--I need the double @ symbol: Opt("ExpandVarStrings", 1) Dim $w = 300, $h = 200 $output = 'GuiCreate("MyGUI", $w$, $h$, (@@DesktopWidth-$w$)/2, (@@DesktopHeight-$h$)/2, 0x04CF0000)' MsgBox(4096,"Result", $output) Edited October 17, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Share this post Link to post Share on other sites
CyberSlug 6 Posted October 17, 2004 Another question, is there any way to get arrays to work? $x[5]$ $x$[5] seem to fail Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Share this post Link to post Share on other sites
Jon 1,009 Posted October 17, 2004 Yeah it needs a leading and trailing $ - otherwise you wouldn't be able to do $foo = "there" msgbox(0, "", "hello$foo$hello") Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Share this post Link to post Share on other sites
CyberSlug 6 Posted October 17, 2004 Workaround for arrays is to use Assign: Opt("ExpandVarStrings", 1) Dim $x = StringSplit("ABCD","");creates array $x[0], ..., $x[4] For $i = 0 To 4 Assign("x" & $i, $x[$i]);create vars x0, ..., x4 Next MsgBox(4096, "Example", "One $x1$ Two $x2$ Three $x3$ Four $x4$") Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Share this post Link to post Share on other sites