Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Validate WIL Variable Name Var Substitution StrClean Reserved Keyword 3074 Expression Continues Past Expected End 3054 Unrecognizable Item Found on Line 3055 Variable Name Over 30 Characters Too Long
You should also add code to confirm the user is not passing a restricted keyword ( For, Select, Pause etc). The WIL.CLR file contains a list of functions and keywords.
input = 'abc' ; ok ;input = '1abc' ; bad - remove int as first charater ;input = 'abc?' ; bad - replace ? with _ ;input = 'abcdefghijklmnopqrstuvwxyz0123456789' ; bad - to many chars, truncate to 30 ;input = 'Pause' ; bad - function name ;input = 'Select' ; bad - keyword name ; Don't allow first character to be a number, remove if found If IsInt(StrSub( input, 1, 1 )) Then input = StrSub( input, 2, -1 ) ; Replace all non-var characters with underscore alpha="abcdefghijklmnopqrstuvwxyz0123456789@_" ; allowed ; Truncate length to 30 characters input = StrSub( input, 1, 30 ) input = StrClean( input, alpha, "_", @FALSE, 2 ) ;Confirm its not a keyword, if so append a leading underscore clrfile = DirHome() : "wil.clr" flag = IniReadPvt( "keywords", input, 0, clrfile ) If flag != 0 Then input = '_':input %input% = 'hello world' Pause('Variable : ', %input% ) Exit
Article ID: W17951
Filename: Validate WIL Variable Name.txt
File Created: 2013:02:26:10:40:50
Last Updated: 2013:02:26:10:40:50