FIND

From STX Wiki
< Programmer Guide‎ | Command Reference
Revision as of 14:05, 17 May 2010 by 193.171.195.8 (talk) (initial import)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

FIND

The FIND command searches a table item for a particular entry and returns this entry's index (if found). The FIND command can only be used with simple tables or the extended table string/name fields.

#pos := FIND table entry field [mask tag case]

-> #pos = 'entryindex' or empty if not found

table
The name of the table item to search.
entry
* for all entries or the index from which to start searching.
field
Index or name of string/name field. This parameter is ignored for simple tables and should be set to *.
mask
The search mask (wildcards are possible).
tag
Search all (0) or tagged (1) fields. The default is 0.
case
Ignore (0) or respect (1) case. The default is 0.
[macro FindStringInTable]
#t := new table *
$#t * 'The big red apple was very juicy'
$#t * 'The blue waves were mesmerizing'
$#t * 'The green man said - "You are coming with me"'
$#t * 'The red dwarf star was a million miles away'
#searchStr := 'red'
do forever
    #i := find $#t '$#i' '*' '*$#searchStr*'
    if '$rc' != 0 break
    um 'The table entry $#i ($#t[$#i]) contains the word "$#searchStr"'
end
delete $#t
exit

Navigation menu

Personal tools