Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
|
The space won't matter..
A somewhat unrelated comment:
? "ERROR: Failed to add printer, reason: ["+@ERROR+"] @SERROR"+@CRLF
while this kind of logging is good to do, this syntax tends to be complicated/crowded. This often leads to other problems...
If you are not defining NoMacrosInStrings, and this message is here simply to troubleshoot, you can greatly simplify the format to
"ERROR: Failed to add printer, reason: [@ERROR] @SERROR" ?
If this is a permanent logging message and you want to follow good practice, you can still simplify it a bit. The "?" is not a print command, it's a shortcut for @CRLF, so you've effectively got a newline command at the beginning and end of that output line. Probably not what you want, and certainly not consistent. The "?", like @CRLF (or pressing ENTER, for that matter) usually comes at the end of a line, not the beginning. The "+" is not required for simple output - replacing them with spaces makes things a bit less jumbled. "+" concatenates a string, which would be appropriate for something like $X = "this " + "and that". Note, too, the rearranged quotes. This was a typo in Richard's original post.
"ERROR: Failed to add printer, reason: [" @ERROR "] " @SERROR ?
None of this will directly fix your print map issue, but not paying attention to the little things will often lead to extra or misplaced quotes, which can have a profound effect on the code that follows. Having clean, well formatted code, and following simple "best practice" rules will go a long way helping to troubleshoot your scripts.
In fact, this kind of output is so important that I have a suite of UDFs to handle it. You can get the MSG() UDF from my web site, which has the following UDFs (and more): MSG(text,flag) - outputs TEXT, suppress CRLF if flag is true Abend(text,error) - outputs TEXT, exits script with ERROR Dbg(text) - outputs TEXT only if Global var DEBUG is true
I'd wager that most seasoned coders have a similar collection.
Glenn
PS - PostPrep (or PPCL, from the top of the Advanced forum) to color-code your script, and Sanity to check basic syntax will go a long way in troubleshooting, too. The Sanity UDF posted here is missing the last 5-6 lines - grab the complete version from my web site.
_________________________
Actually I am a Rocket Scientist!
|