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

@WORD[], quoted string?

Discussion in 'Support' started by vefatica, Jul 25, 2010.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,970
    Likes Received:
    30
    The help says:"If string is double quoted, you must specify sep_list".

    But apparently when string is double quoted, @word sees only **one** word.

    Code:
    e:\logs\mercury> echo %@word[" ",0,"a b c e"]
    "a b c e"
    
    e:\logs\mercury> echo %@word[" ",1,"a b c e"]
    ECHO is OFF
    If it's WAD, @word seems of no use at all with a quoted string.
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,869
    Likes Received:
    83
    , quoted string?

    WAD (and it's behaved this way for more than 15 years!).

    If the first argument to @WORD is a double quote, it's assumed to be a
    separator list. You can have any number of subsequent arguments, quoted or
    not -- but @WORD (as with batch arguments) does not strip the double quotes
    and parse inside the quoted arguments.

    Rex Conn
    JP Software
     
  3. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,970
    Likes Received:
    30
    On Sun, 25 Jul 2010 18:52:56 -0400, rconn <>
    wrote:

    |---Quote---
    |> The help says:"If* string* is double quoted, you must specify
    |> *sep_list*".
    |>
    |> But apparently when string is double quoted, @word sees only **one**
    |> word.
    |---End Quote---
    |WAD (and it's behaved this way for more than 15 years!).
    |
    |If the first argument to @WORD is a double quote, it's assumed to be a
    |separator list. You can have any number of subsequent arguments, quoted or
    |not -- but @WORD (as with batch arguments) does not strip the double quotes
    |and parse inside the quoted arguments.

    What is the meaning of the line I quoted from the help?

    "If string is double quoted, you must specify sep_list."
     
  4. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,869
    Likes Received:
    83
    , quoted string?

    If the first character of the string is double quoted, you must specify
    sep_list. It doesn't mean you can only have one quoted string.

    Rex Conn
    JP Software
     
  5. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,970
    Likes Received:
    30
    On Sun, 25 Jul 2010 20:45:24 -0400, rconn <>
    wrote:

    |If the first character of the string is double quoted, you must specify
    |sep_list. It doesn't mean you can only have one quoted string.

    It doesn't seem to be true that I must specify a sep_list:

    Code:
    v:\> echo %@word[0,"abc" def "ghi"]
    "abc"
    
    v:\> echo %@word[1,"abc" def "ghi"]
    def
    
    v:\> echo %@word[2,"abc" def "ghi"]
    "ghi"
     
  6. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,869
    Likes Received:
    83
    , quoted string?

    Don't count on it.

    Rex Conn
    JP Software
     
  7. dcantor

    Joined:
    May 29, 2008
    Messages:
    507
    Likes Received:
    3
    The work-around is to specify quotes within the list of separators, as
    Code:
    echo %@word["^q^s",3,"a b c d e"]
    d
    
    That doesn't help if there are multiple separate quoted substrings, but it does help in the case where you've got one string that needs to be quoted.
     
  8. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,970
    Likes Received:
    30
    , quoted string?

    On Sun, 25 Jul 2010 23:15:15 -0400, dcantor <>
    wrote:

    |---Quote (Originally by vefatica)---
    |On Sun, 25 Jul 2010 18:52:56 -0400, rconn <>
    |wrote:
    |
    ||---Quote---
    ||> The help says:"If* string* is double quoted, you must specify
    ||> *sep_list*".
    ||>
    ||> But apparently when string is double quoted, @word sees only **one**
    ||> word.
    ||---End Quote---
    ||WAD (and it's behaved this way for more than 15 years!).
    ||
    ||If the first argument to @WORD is a double quote, it's assumed to be a
    ||separator list. You can have any number of subsequent arguments, quoted or
    ||not -- but @WORD (as with batch arguments) does not strip the double quotes
    ||and parse inside the quoted arguments.
    |
    |What is the meaning of the line I quoted from the help?
    |
    |"If string is double quoted, you must specify sep_list."
    |---End Quote---
    |The work-around is to specify quotes within the list of separators, as
    |
    |Code:
    |---------
    |echo %@word["^q^s",3,"a b c d e"]
    |d
    |---------
    |That doesn't help if there are multiple separate quoted substrings, but it does help in the case where you've got one string that needs to be quoted.

    Do you suppose that's what the help had in mind?
     
  9. dcantor

    Joined:
    May 29, 2008
    Messages:
    507
    Likes Received:
    3
    Re: , quoted string?

    No clue. I ran into the same problem a couple of years ago, and Rex answered in the same way then. On a hunch, I included the ^Q into the separator list, and, presto, it just worked. IIRC, I suggested then that the help could hint that ^Q should be included in the separator list.
     

Share This Page