Gene Posted November 27, 2005 Share Posted November 27, 2005 Language Reference - CommentsAlthough only one statement per line is allowed, a long statement can span multiple lines if an underscore " _" preceeded by a blank is placed at the end of a "broken" line. String definition cannot be splitted in several lines, concatenation need to be used.The text above could be more appropriately restated as:Language Reference - CommentsAlthough only one statement per line is allowed, a long statement can span multiple lines if an underscore " _" preceeded by a blank space is placed at the end of a "broken" line. String definition cannot be split into several lines, concatenation must be used. [font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right... Link to comment Share on other sites More sharing options...
PartyPooper Posted November 27, 2005 Share Posted November 27, 2005 (edited) I take it that 'string definition' is referring to variables and not the actual 'text' like in the following examples: GUICtrlCreateLabel("This will work",25, 20, 340, 420, $SS_LEFT) $var = "This will work" GUICtrlCreateLabel($var,25, 20, 340, 420, $SS_LEFT) GUICtrlCreateLabel("This " & _ "will work",25, 20, 340, 420, $SS_LEFT) $var ="This" & _ "will work" GUICtrlCreateLabel($var,25, 20, 340, 420, $SS_LEFT) $var ="This" _ "won't work" GUICtrlCreateLabel($var,25, 20, 340, 420, $SS_LEFT) Edit: removed the concat symbol from last example Edited November 27, 2005 by PartyPooper Link to comment Share on other sites More sharing options...
LxP Posted November 27, 2005 Share Posted November 27, 2005 Nope, 'string definition' refers to any sequence of characters within single or double quotes. ; This will work Local $Var = 'This is a ' _ & 'string' ; This will not work Local $Var = 'This is a _ string' I would suggest a comment along the lines of: One string cannot be split across lines. The starting quote of a string must be on the same line as the ending quote. Remember however that one string can always be split into two via use of the & operator:'This is a string' is equivalent to 'This is ' & 'a string' (The above example could be pasted here.) Link to comment Share on other sites More sharing options...
LxP Posted November 27, 2005 Share Posted November 27, 2005 Perhaps this is better:Each line of a script may contain no more than one statement. Long statements can be spanned across multiple lines by ending each unfinished line with a space and an underscore like so:$sTmpFile = FileOpenDialog('Select File', _ '::{20D04FE0-3AEA-1069-A2D8-08002B30309D}', _ 'Executables & DLLs (*.EXE, *.DLL, *.OCX, *.ICL)')Function names, variable names and values should be considered atomic, i.e. you can not break a line in the middle of one. To span a long string across multiple lines you must split the string into more than one piece using the & operator, which you can then concatenate across lines:MsgBox(0x40, 'Information', 'This was one unusually long string, ' _ & 'however it made my code look weird due to its length. This ' _ & 'cause me to split it into a few pieces and concatenate those ' _ & 'pieces together over a couple lines.') Link to comment Share on other sites More sharing options...
PartyPooper Posted November 27, 2005 Share Posted November 27, 2005 (edited) Well, I kinda get what you mean, however, my understanding is that while a string definition may be concatenated, I believe a variable definition can't (as in my examples earlier): GUICtrlCreateLabel("This " & _ "will work",25, 20, 340, 420, $SS_LEFT) $var ="This" & _ "won't work" GUICtrlCreateLabel($var,25, 20, 340, 420, $SS_LEFT) While the first example worked, the second example failed on my computer. I guess it doesn't matter either way, but I tend to do the following: MsgBox(0x40, 'Information', 'This was one unusually long string, ' & _ 'however it made my code look weird due to its length. This ' & _ 'cause me to split it into a few pieces and concatenate those ' & _ 'pieces together over a couple lines.') In hindsight Gene, it may be better written as: A string definition can be split into several lines, however, concatenation using the '&' is mandatory in this case. Edit: both of my examples above work, however, the one below doesn't (which is correct): $var ="This" _ "won't work" GUICtrlCreateLabel($var,25, 20, 340, 420, $SS_LEFT) Edited November 27, 2005 by PartyPooper Link to comment Share on other sites More sharing options...
LxP Posted November 27, 2005 Share Posted November 27, 2005 Hmm... both examples work for me using the latest beta. Link to comment Share on other sites More sharing options...
PartyPooper Posted November 27, 2005 Share Posted November 27, 2005 That's scary. I tested them with the latest beta plugging values into some pre-written stuff. I'll code from scratch and confirm whether or not I had a brainfart ;-) Link to comment Share on other sites More sharing options...
PartyPooper Posted November 27, 2005 Share Posted November 27, 2005 Works. I musta done something stupid again. :-( Link to comment Share on other sites More sharing options...
Gene Posted November 27, 2005 Author Share Posted November 27, 2005 Works. I musta done something stupid again. :-(H'mmmn, this is an interesting discussion on the defintion of the word "string" as it relates to AutoIt. However, I was just hoping to get the noted Help file entry changed to reflect a more standard usage of the English language as contaminated by us Americans, oops, maybe I should have said "Citizens of the United States of America" Language Reference - CommentsAlthough only one statement per line is allowed, a long statement can span multiple lines if an underscore " _" preceeded by a blank is placed at the end of a "broken" line. String definition cannot be splitted in several lines, concatenation need to be used.The text above could be more appropriately restated as:Language Reference - CommentsAlthough only one statement per line is allowed, a long statement can span multiple lines if an underscore " _" preceeded by a blank space is placed at the end of a "broken" line. String definition cannot be split into several lines, concatenation must be used. [font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now