[*:6ltpk5io]Added capability to call functions using traditional command syntax, with some limitations.
[*:6ltpk5io]Added capability to call commands using function() syntax.
[*:6ltpk5io]Fixed 'var x' in global scope.
[*:6ltpk5io]Fixed: ErrorLevel not initialized when a new thread starts.
[*:6ltpk5io]Fixed: Contents of ErrorLevel not freed when the thread ends.
[*:6ltpk5io]Added Files, Reg, Read and Parse as sub-commands of Loop.
[*:6ltpk5io]Combined RootKey and SubKey params of LoopReg and Reg commands.
[*:6ltpk5io]Combined IncludeFolders/Subkeys? and Recurse? params to aid memorization.
[*:6ltpk5io]Changed For-loop to localize its variables.
[*:6ltpk5io]Renamed Asc() to Ord() -- it's not ASCII anymore.
[*:6ltpk5io]Updated Ord() and Chr() to support supplementary characters.
[*:6ltpk5io]Replaced the final parameter of StrReplace with OutputVarCount and Limit, similar to RegExReplace.
[*:6ltpk5io]Changed InputBox to use a flex-list of options similar to Gui Show etc.
All commands can now be called as functions, except for control flow statements such as Return and Exit. ExitApp is also excluded, for consistency. Currently commands and functions are still separate, but commands are automatically wrapped on first use as a function (if no function with the same name exists). The translation rules are:
[*:6ltpk5io]If the command's first parameter is an output variable and the second parameter is not, it becomes the return value. Otherwise, any value which the command stores in ErrorLevel is returned and ErrorLevel itself is restored to its former value.
[*:6ltpk5io]The remaining output variables are handled like ByRef parameters, except that an exception is thrown if the function is called incorrectly. Passing an empty string is equivalent to omitting the parameter, but any other value (which is not a variable reference) is not allowed.
[*:6ltpk5io]Commands which normally accept an input variable do not require a variable reference; an internal temporary variable is used automatically.
[*:6ltpk5io]If a runtime error occurs, an exception is always thrown even if try
is not used.Although it's basically one big hack, it seems to work very well. Unfortunately the converse functionality isn't quite as complete:Function, Args
All functions can now be called as commands, including library functions which haven't been manually #included. The translation rules are currently:
[*:6ltpk5io]The return value is always discarded.Update:
In alpha 26 and later, an output variable is inserted at the beginning of the parameter list if the function is built-in or contains a "return".
[*:6ltpk5io]All parameters support % for forcing an expression, and are not expressions by default.
[*:6ltpk5io]ByRef parameters are treated like input variables. Expressions such as % var := "value"
aren't fully supported (the variable reference is not passed to the function). However, % var
is okay due to an optimization which converts it to a non-expression.
[*:6ltpk5io]All other parameters default to normal text mode. This includes all parameters of built-in functions, so to pass a variable reference, you must write % var
(but again, % var := "value"
will only pass the value).
[*:6ltpk5io]The args are parsed before the function name can be resolved (and the number of parameters determined), so literal commas must always be escaped, even in the function's final parameter.Most of the built-in
functions probably need an output variable to be useful and virtually all of them return something useful, if not necessary. However, if the output variable is always present, command syntax is less appealing for user-defined functions which have no return value. For example, AlertBox,, Text
isn't very nice, especially if, like me, you prefer to omit the initial comma.Registry Commands
I believe it is more convenient and intuitive for the root key and subkey to be specified together than as two separate parameters. Instead of RootKey, Key
, write RootKey\Key
. To connect to a remote registry, use \\ComputerName\RootKey\Key
instead of \\ComputerName:RootKey, Key
Loop Files, FilePattern [, Mode
Loop Reg, RootKey\Key
Loop Read, InputFile [, OutputFile]
Loop Parse, InputVar [, Delimiters, OmitChars]
Mode supersedes the old IncludeSubkeys?/IncludeFolders? and Recurse? parameters. Its meaning is more obvious when reading the source code and it should be easier to remember. Instead of a number, it is a case-insensitive string of characters separated by optional spaces or tabs, in any order:
[*:6ltpk5io]F (file) or V (value): include files or registry values.
[*:6ltpk5io]D (directory) or K (key): include directories or registry keys.
[*:6ltpk5io]R (recurse): recurse into subdirectories or subkeys.For example, Loop Files, *, FDR
recursively loops through all files and folders in the working directory.
Currently the compact form (LoopFiles, LoopReg, LoopRead and LoopParse) is still supported since it doesn't require any extra code. This may or may not be removed, depending on community feedback.StrReplace
StrReplace, OutputVar, InputVar, SearchText [, ReplaceText, OutputVarCount, Limit
Usage is now almost the same as RegExReplace (when function syntax is used). If Limit is omitted, the default is unlimited. ErrorLevel can be used as the OutputVarCount; otherwise ErrorLevel is not affected. These changes were very simple because it was apparently already designed to support a variable limit. I opted not to implement a StartingPosition parameter since it wasn't as simple, and it can be added later without causing problems. I'm not sure how useful it would be, anyway.InputBox
InputBox, OutputVar [, Title, Prompt, Options
That's quite a few less parameters to memorize. The Options parameter accepts a string of zero or more case-insensitive options delimited by a space or tab, similar to Gui control options. For example, this includes all supported options: x0 y0 w100 h100 T10.0 Password*
. T is timeout and Password has the same usage as the equivalent Edit control option.