Programmer Guide/Command Reference/KEYWORD: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
==KEYWORD==
== KEYWORD ==


<code><var>var</var> := KEYWORD <var>testValue keywordList</var> [ /F [ /C ]]</code>
=== Searching for a keyword or its abbreviation ===


-> var = 'indexOfKeyword'InList or <code>–1</code> if not found
The <code>KEYWORD</code> command searches for a keyword, or for the (non-unique) abbreviation of a keyword, in a list of keywords. It is supplied a single string <var>testValue</var> (the keyword to search, or its abbreviation), and a list of blank-separated keywords, <var>keywordList</var>. The command returns the zero-based index of the first keyword in <var>keywordList</var> equal to (if option <code>/Full</code> is supplied), or starting with, <var>testValue</var>. If <var>keywordList</var> does not contain an appropriate keyword, the command will return -1.


;<var>testValue</var>
<var>var</var> := KEYWORD [ /Full [ /Casesensitive ] ] /- <var>testValue keywordList</var>


:The keyword or index to test for in the <var>keywordList</var>.
;<var>testValue</var>: the keyword to locate in <var>keywordList</var>, or its abbreviation. Note that the <code>KEYWORD</code> command does not expect a unique abbreviation - it will simply return the first keyword starting with <code>testValue</code>, even if there are dozens more.
;<var>keywordList</var>: a blank-separated list of keywords
;<code>/Full</code>: if specified, the function searches for the first entry exactly equal to <var>testValue</var>, meaning that abbreviations will not be found.
;<code>/Casesensitive</code>: If used in conjunction with <code>/Full</code>, the comparison is case sensitive.


;<var>keywordList</var>
// will return 0, because "toll" starts with "to"
#index := keyword /- to toll too to Toledo
// will return 2, because "/Full" looks for strict equality
#index := keyword /Full /- to toll too to Toledo
// will return -1, because the keyword list does not contain "To"
#index := keyword /Full /Casesensitive /- To toll too to Toledo
// will return '''0''', because "/Casesensitive" is valid only with "/Full"
#index := keyword /Casesensitive /- To toll too to Toledo


:A blank separated list of keywords.


;<var>/F</var>
=== Checking for the presence of an index ===


:If specified, the whole word is compared (abbreviations are not found).
Instead of a keyword, or its abbreviation, the <code>KEYWORD</code> command may be supplied an integer. It will then check if this integer is a valid index in the respective keyword list. If this is the case, it will return the unmodified index. Otherwise, it will return -1.


;<var>/C</var>
<var>var</var> := KEYWORD <var>index keywordList</var>
 
:If used in conjunction with /F, the comparison is case sensitive.
 
Find a keyword in a list of keywords. The value <var>test</var> can be an index (0 to count-1), a keyword or an abbreviation of a keyword. The command returns the zero-based index or <code>-1</code> if the <var>testValue</var> is not in the keyword list. See also <code>[[Programmer Guide/Command Reference/WORD|WORD]]</code>.

Revision as of 15:41, 11 April 2011

KEYWORD

Searching for a keyword or its abbreviation

The KEYWORD command searches for a keyword, or for the (non-unique) abbreviation of a keyword, in a list of keywords. It is supplied a single string testValue (the keyword to search, or its abbreviation), and a list of blank-separated keywords, keywordList. The command returns the zero-based index of the first keyword in keywordList equal to (if option /Full is supplied), or starting with, testValue. If keywordList does not contain an appropriate keyword, the command will return -1.

var := KEYWORD [ /Full [ /Casesensitive ] ] /- testValue keywordList
testValue
the keyword to locate in keywordList, or its abbreviation. Note that the KEYWORD command does not expect a unique abbreviation - it will simply return the first keyword starting with testValue, even if there are dozens more.
keywordList
a blank-separated list of keywords
/Full
if specified, the function searches for the first entry exactly equal to testValue, meaning that abbreviations will not be found.
/Casesensitive
If used in conjunction with /Full, the comparison is case sensitive.
// will return 0, because "toll" starts with "to"
#index := keyword /- to toll too to Toledo

// will return 2, because "/Full" looks for strict equality
#index := keyword /Full /- to toll too to Toledo

// will return -1, because the keyword list does not contain "To"
#index := keyword /Full /Casesensitive /- To toll too to Toledo

// will return 0, because "/Casesensitive" is valid only with "/Full"
#index := keyword /Casesensitive /- To toll too to Toledo


Checking for the presence of an index

Instead of a keyword, or its abbreviation, the KEYWORD command may be supplied an integer. It will then check if this integer is a valid index in the respective keyword list. If this is the case, it will return the unmodified index. Otherwise, it will return -1.

var := KEYWORD index keywordList

Navigation menu

Personal tools