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

Kind of a out-of-curiosity question re. the "Function" command...

Discussion in 'Support' started by mathewsdw, Dec 17, 2011.

  1. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    Just as a preface, all of the following is just for illustrative purposes only and not anything close to what I was trying to "accomplish".

    Doing this:
    Code:
    Function MMM=`%1 %2 %3 %4 %5`
    and entering this command:
    Code:
    Echo %@MMM[This Is a Test]
    yeilds:
    Code:
    This Is a Test
    pretty much what you would expect.

    But doing this:
    Code:
    Function MMM=`%*`
    and entering the same command:
    Code:
    Echo %@MMM[This Is a Test]
    yeilds:
    Code:
    ECHO is OFF
    Why is that?
     
  2. Charles Dye

    Charles Dye Super Moderator
    Staff Member

    Joined:
    May 20, 2008
    Messages:
    3,277
    Likes Received:
    38
    Shouldn't that be %$ rather than %* ?
     
  3. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    Actually, Charles, no; although it really wouldn't make any practical difference in this case. "%$" is "the complete command tail, modified by SHIFT", whereas "%*" is "the complete command tail, unmodified by SHIFT", and since I am not (never will) be doing any "SHIFT" commands in this "application", it really doesn't matter in this case. (And frankly, that being the case, I have a slight bias for "%*"', I use "%$" only when I am explicitly doing shifts.)

    - Dan

    P. S. Thank you, Charles!!! You were correct!!!! I just did that "experiment" after originally hitting the "Save Changes" button on this; I thought "Just for the heck of let's see what this does...", and it does exactly what I would want it do. But do you know why "%*" doesn't work???
     
  4. David Marcus

    Joined:
    Jun 4, 2008
    Messages:
    646
    Likes Received:
    1
    The Help page for "Function" says that "%$" does what you want, but doesn't mention "%*". Since the latter isn't mentioned, your function is presumably just returning "%*", regardless of the argument. So, the result you get is the same as doing "echo %*".
     
  5. mathewsdw

    Joined:
    May 24, 2010
    Messages:
    855
    Likes Received:
    0
    You are, of course, right as always, David. (My inability to see is, as oft mentioned before, a real handicap.) However, they not only do they not behave the way I would expect from the documentation, the "results" can actually be far worse (more on that at the bottom of this). So, to "illustrate" these things, here is a TCC "log".
    Code:
       Sat  Dec 17, 2011  11:45:40p
    
    ISO8601 plugin v1.1.1 loaded.
    SafeChars plugin v1.5.7 loaded.
    
    TCC  12.11.76   Windows 7 [Version 6.1.7601]
    Copyright 2011  Rex Conn & JP Software Inc.  All Rights Reserved
    Registered to Daniel Mathews
     
    [Z:\]Function XPer=`%$`
    
    [Z:\]Echo %@XPer[First 2ndParm Third 4th Fifth 6th Seventh]
    First 2ndParm Third 4th Fifth 6th Seventh
    
    [Z:\]Function XPer=`%*`
    
    [Z:\]Echo %@XPer[First 2ndParm Third 4th Fifth 6th Seventh]
    ECHO is OFF
    
    [Z:\]Function XPer=`%3$`
    
    [Z:\]Echo %@XPer[First 2ndParm Third 4th Fifth 6th Seventh]
    Third 4th Fifth 6th Seventh
    
    [Z:\]Function XPer=`%-3$`
    
    [Z:\]Echo %@XPer[First 2ndParm Third 4th Fifth 6th Seventh]
    2ndParm
    
    So, from the documentation:

    However, the first parameter ("First"), is not being printed.

    Code:
    [Z:\]Function XPer=`%-2$`
    
    [Z:\]Echo %@XPer[First 2ndParm Third 4th Fifth 6th Seventh]
    ECHO is OFF
    
    Again, the first parameter is not being printed (kind of obviously, I would say).

    Code:
    [Z:\]Function XPer=`%-1$`
    
    [Z:\]Echo %@XPer[First 2ndParm Third 4th Fifth 6th Seventh]
    
    And here is the end of the whole thing, because at this point TCC just crashed. (Since I knew it was going to crash from a previous run-through, I saved this to a file before I issued the above command.)

    What's kind of remarkable to me is that nobody (apparently even you) has "noticed" this behavior before.

    - Dan
     
  6. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,784
    Likes Received:
    29
    That does, indeed, cause a crash. I'm confident Rex will look into it.
     

Share This Page