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

Weird @Index function result...

Discussion in 'Support' started by mathewsdw, Aug 11, 2011.

  1. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    Here is the code in question:
    Code:
    Set FullFileName=%@Trim[%@Right[-53,%Line]]
    Set M=%@Index[%FullFileName,\,-1]
    @Echo FullFileName: %FullFileName
    @Echo Index: %@Index[%FullFileName,\,-1]   M: %M
    
    Here is the output of the above code:
    Code:
    FullFileName: Fact.txt
    Index: -24   M: -24
    
    The question is obvious: what is going on here?
     
  2. Jim Cook

    Joined:
    May 20, 2008
    Messages:
    604
    Likes Received:
    0
    FullFileName: Fact.txt
    Index: -1 M: -1
    I get results that are expected, but I did prepend one line to simulate your
    input.

    set Line=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaFact.txt

    You do not mention what %Line contains. Perhaps there's something causing
    trouble in the original input. Does it have special characters (e.g.
    backspace)? I still can't come up with a reason for -24.

    TCC 12.11.73 x64 Windows 7 [Version 6.1.7600]
    TCC Build 73 Windows 7 Build 7600

    On Thu, Aug 11, 2011 at 15:13, mathewsdw <> wrote:




    --
    Jim Cook
    2011 Monday: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
    Next year they're Tuesday.
     
  3. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    Jim, I modified the batch file slightly:
    Code:
    Set FullFileName=%@Trim[%@Right[-53,%Line]]
    Set M=%@Index[%FullFileName,\,-1]
    @Echo Line: "%Line"
    @Echo FullFileName: %FullFileName
    @Echo Index: %@Index[%FullFileName,\,-1]   M: %M
    
    Here's the new output:
    Code:
    Line: "2011-07-03 17:35:36 ....A     13862737      4626295  Fact.txt"
    FullFileName: Fact.txt
    Index: -24   I: -24
    
    (Note that the line is being printed out enclosed in double quotes.) And the line being parsed does not, as far as I know, contain any non-printable characters (and there's no reason why it would). Doesn't really seem to explain anything.
     
  4. Jim Cook

    Joined:
    May 20, 2008
    Messages:
    604
    Likes Received:
    0
    I'm still getting desirable results. Any chance that @index has been changed
    by a user function? I don't have good ideas, I'm afraid.

    On Thu, Aug 11, 2011 at 19:44, mathewsdw <> wrote:




    --
    Jim Cook
    2011 Monday: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
    Next year they're Tuesday.
     
  5. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    Jim, I would say not only "no", but "absolutely not"! This is because, among several other things, this same instance of the"@Index" function does work in this batch file most of the time! (And the workaround that seems to work for the moment is to replace "Iff %@Index[...] == -1 Then" by "Iff %@Index[...] LT 0 Then".
     
  6. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,854
    Likes Received:
    83
    I can't begin to guess (and certainly can't begin debugging) without knowing
    what %LINE contains.

    Rex Conn
    JP Software
     
  7. Jim Cook

    Joined:
    May 20, 2008
    Messages:
    604
    Likes Received:
    0
    On Thu, Aug 11, 2011 at 21:42, rconn <> wrote:


    I believe a later post in this same thread said it contained this, without
    quotes:

    "2011-07-03 17:35:36 ....A 13862737 4626295 Fact.txt"

    Using that, I still can not find any trouble.





    --
    Jim Cook
    2011 Monday: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
    Next year they're Tuesday.
     
  8. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    Rex,

    You didn't see the previous where I answered this question for Jim Cook. Here is the relevant part of that reply:
    Code:
    Set FullFileName=%@Trim[%@Right[-53,%Line]]
    Set M=%@Index[%FullFileName,\,-1]
    @Echo Line: "%Line"
    @Echo FullFileName: %FullFileName
    @Echo Index: %@Index[%FullFileName,\,-1]   M: %M
    
    Here's the new output:
    Code:
    Line: "2011-07-03 17:35:36 ....A     13862737      4626295  Fact.txt"
    FullFileName: Fact.txt
    Index: -24   I: -24
    
    (Note that the line is being printed out enclosed in double quotes.) And the line being parsed does not, as far as I know, contain any non-printable characters (and there's no reason why it would).

    And Rex, I would be perfectly OK with sending you the whole .btm file as well as its input file if that is what you would like. I'm having another really weird error, also, that I'm putting that in another post, so that might be a good idea.
     

Share This Page