Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

@WORD[], quoted string?

May
12,834
163
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.
 
, quoted string?

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

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
 
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."
 
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"
 
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."
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.
 
, 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?
 
Re: , 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?

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.
 

Similar threads

Back
Top