@WORD[], quoted string?

May 20, 2008
11,400
99
Syracuse, NY, USA
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.
 

rconn

Administrator
Staff member
May 14, 2008
12,344
149
, 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
 
May 20, 2008
11,400
99
Syracuse, NY, USA
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."
 
May 20, 2008
11,400
99
Syracuse, NY, USA
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"
 
May 29, 2008
570
4
Groton, CT
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.
 
May 20, 2008
11,400
99
Syracuse, NY, USA
, 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?
 
May 29, 2008
570
4
Groton, CT
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
Thread starter Title Forum Replies Date
W Starting program for word to pdf conversion (difference cmd and tcc) Support 13
dcantor @WORD vs @FIELD in v 22 Support 3
rps How to? @word help Support 6
J Documentation New help system: "skip word list" Support 11
Joe Caverly Word Count using TPIPE Support 10
vefatica @WORD[1-2,...] ? Support 2
Stefano Piccardi TPIPE and word to text conversion Support 4
G WAD PDIR @IF bug, @WORD bug Support 8
M What can I do to "word around" this problem? Support 8
T @Word from Lines with Pipes Support 3
R A problem using find in list when word wrap? Support 2
cgunhouse ProcessMonitor Does Not Work With Quoted Process Name Support 5
cgunhouse ProcessMonitor Does Not Work With Quoted Process Name Support 0
S FFIND and quoted strings Support 4
P Inserting string into a variable. Support 3
M Backquoted parameters used in GoSub don't pass string as a single parameter Support 2
H Behavior change re piping a string to a Java program Support 1
C email[string] function Support 10
D Finding a string position in a larger string Support 2
MikeBaas How to...extract a string from a .json-file? Support 10
D Faster string search Support 8
D btm file command line augments comparing for string or math. Support 12
B How can TCC make an output as a part of command string Support 2
vefatica DO /L, where did my string go? Support 6
Alpengreis A leading withespace in Hash-String is not included? Support 1
T TPipe: Replacing String with Double Quotes Support 3
J WAD utf8decode string only results in ? chars Support 2
scooter_de How to? How to split the a string? Support 4
C custom string compare? Support 8
C Best way to validate a string is a YYYYMMDD Support 7
Phileosophos Documentation TPIPE /string type code confusion Support 4
vefatica WAD "tokens=*" and literal string Support 4
vefatica Back-refs in TPIPE's /replace's replacement string? Support 2
vefatica @B64ENCODE[s,string]? Support 8
vefatica Random access to the characters in a string? Support 4
H "Here-String" redirection not working Support 6
C Can't remove leading quote from a string Support 2

Similar threads