1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Why does this code produce these results?

Discussion in 'Support' started by mathewsdw, Dec 30, 2012.

  1. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    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.
     

    Attached Files:

  2. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    Dan:
    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]
    enddo

    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
     
  3. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    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.
     

Share This Page