The WIL language has a powerful substitution feature which inserts the contents of a string variable into a statement before the line is parsed. However, substitution should be used with caution. Do not use variable substitution, unless absolutely necessary. Many problems can be created, simply by using variable substitution. For example, if you have a large string variable, and you attempt variable substitution, you will receive an error that the line is too long. This occurs because the contents of the string variable are substituted into the line before the line gets executed. No single line can exceed 2048 characters. It is a better idea, to build a string variable using the function StrCat. Example:MyName="George" NewStr=StrCat("Hello, My name is: ", MyName) Message("Name Tag",NewStr)
If it is absolutely necessary to substitute the contents of a variable in the statement, simply put a percent-sign (%) on both sides of the variable name. Examples:mycmd = "DirChange('c:\')" ;set mycmd to a command %mycmd% ;execute the command
Or consider this one: IniWrite("PC", "User", "Richard") name = IniRead("PC", "User", "somebody") message("", "Thank you, %name%")
will produce this message box:
To put a single percent-sign (%) on a source line, specify a double percent sign(%%). This is required even inside quoted strings. Note: The length of a line, after any substitution occurs, may not exceed 2048 characters. If you choose to put a comment at the end of a line, that includes a percent sign, you must specify %%. percent = value * 0.5 ; 50%% of value is
|
§ Step by step guide to learning WIL § Notes
|