Donna asks:
> i'm wondering how to change the default delimiters for
> word/xword.
You cannot change the defaults but you can override them by specifying
a string value for word's or xword's second parm.
> here's the (rather un-)help(-ful) text
> regarding delimiters:
>
> The default delims are a space, a comma,
> a semicolon, an equals sign, left and right
> parentheses,
> left and right brackets, single quote, double
> quote,
> and tab.
>
> that's lovely....but how do you change the defaults?
These are the default delimiters if the caller chooses to omit
the second parm. They cannot be changed (that is you cannot
create a different set of DEFAULT values) but you can specify
any delimiters you wish by supplying the second parm.
> use the following string and code snippet as an example:
>
> setvar x 'remote :node hello sesname,mgr/pass.account,group'
>
> setvar i 0
> setvar xx x
> while xx > ' ' and i < 10
> setvar i i +1
> setvar x!i xword(xx,' .,/')
> endwhile
> showvar x@
>
> (the i<10 is there to keep the code from going into an
> endless loop <sigh>)
>
> i want to extract each 'word' from the string contained in x
> (or xx). if my delimiters are a space, period, comma and
> slash -- you'd think that code should work. i should get
> x1 = 'remote'
> x2 = ':node'
> x3 = 'hello'
> ...and so on.... but i don't :-( any thoughts?
There is a an example of doing this (and more) in my CI Programming
talk on Jazz at:
http://jazz.external.hp.com/papers/SolSymposium_03/CIProgramming_files/frame
.htm
see the notes for slide 54 "string manipulations"
Anyway, this will work:
setvar x 'what you have above'
setvar i 0
while setvar(x![i+1],word(x,,setvar(i,i+1))) <> "" do
endwhile
showvar x@
X = remote :node hello sesname,mgr/pass.account,group
X1 = remote
X2 = :node
X3 = hello
X4 = sesname
X5 = mgr/pass.account
X6 = group
X7 =
It can be refined or fine-tuned as needed.
> ps -- extra credit for finding the communicator that talks
> about word or xword....
word() first appeared in 5.5 (base) and is described at:
http://jazz.external.hp.com/papers/Communicator/5.5/ci_enhancements.html
xword() first appeared in 6.0 (base) and is described at:
http://www.docs.hp.com/mpeix/onlinedocs/30216-90269/30216-90269.html
Hope this helps,
Jeff Vance, vCSY
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|