Why does this code produce these results?

May 24, 2010
Northlake, Il
And, more importantly, what can I do about it? The code in question (which has been extracted and cut down from the actual code in question to illustrate the problem) is contained in the attached zip file. And the results of running that code are also in the attached zip file. I apologize for the inconvenience that that causes, but when I put the code (important part being %Index[%CharSetInstr[%I,1,%CharSet]]) inline in a CODE section in this posting, it gets "decorated" for reasons I totally don't understand with open and close EMAIL tags.
So if you look at the (very simple!) code and the (also vey simple!) resulting output, you will see that the code is completely unable to handle the open parenthesis properly. Frankly, I really don't understand (nor care, when you come right down to it) what the open parenthesis means in these circumstances. I just know that the data that I will ultimately be processing will contain open parenthesis.


  • Sample.zip
    653 bytes · Views: 148
May 20, 2008
Elkridge, MD, USA
When the character selected from CharSet is left parenthesis "(" it confuses the parser. Use %@SafeExp[@Instr[%I,1,%Charset]] - it works!
Another simplification - use the syntax below:
do c in /c %CharSet
@Echo %@SafeEnv[c] %@Index[%Charset,%c]

Advantages of DO /C vs. FOR:
1/ no need to determine character count in CharSet - automatic (you may use an explicit loop counter)
2/ character of interest is automatically extracted, need not be extracted more than once
3/ DO loops can be debugged via BDEBUGGER, FOR cannot
HTH, Steve
May 24, 2010
Northlake, Il
Thank you Steve, that will do it. (And I understood that it was confusing the parser, I just didn't (and still don't) know why. Not that it really matters.) As far as the "Do" you suggest goes, it's just one more instance in the plethora of capabilities of this product. Sadly for me, there's far more than my limited memory can handle.

Similar threads