GoFiler Legato Script Reference
Legato v 1.5d Application v 5.25a
|
Table of Contents | < < Previous | Next >> |
Chapter Five — General Functions (continued)
Overview
The ScanString function scans a list of strings (or tokens) and returns an index position to the reference list.
Syntax/Parameters
Syntax
int = ScanString ( string data, string match, [boolean case], [int mode] );
Parameters
data
A string containing a list of items to scan. See Remarks for formatting.
match
A string to match within the list. The match is case-sensitive. the match string should not contain leading or trailing spaces.
case
An optional boolean value indicating whether to search using case sensitivity. The default value is TRUE.
mode
An optional int specifying the scan mode. The default is SCAN_STRING_AUTO.
Return Value
Returns an int as the zero-based index to the item in the list or -1 for failure (not found).
Remarks
The ScanString function examines the incoming data parameter to determine if it is a line, comma or space delimited list. If a determination cannot be made, the string will be compared after trimming spaces.
The scan function is useful for matching simple linear non-array lists or sets of string data and it does not care about item order or duplicates. Unlike the InString, IsInString or FindInString functions, the item must be matched in its entirety. In addition, the item position, not the character position, is returned.
Since the function employs a linear search, ScanString is not recommended for repetitively searching long lists of data.
The scan method is determined by the mode parameter which is SCAN_STRING_AUTO by default. The modes are as follows:
SCAN_STRING_AUTO Auto Detect List Type
SCAN_STRING_LINES List as Line Delimited Values
SCAN_STRING_COMMA List as Comma Delimited Values
SCAN_STRING_SPACES List as Space Delimited Values
In auto mode, the delimiter determination is performed by checking for line endings (0x0D), then commas and finally space. Note that a single item list will simply compare data to match. As the function is performed, each item is trimmed for spaces prior to comparing to the match parameter, accordingly the match parameter should not contain trailing or leading spaces. Use caution if the compare data contains spaces and the match data also contains spaces, the function will not match since it will assume the incoming data is a list delimited by spaces.
Example
An example including all modes:
handle hWP; string s1, s2, s3, s4, s5, ref; int i1, i2, i3, i4; int ix; s1 = "Horse Cat Dog Frog Log Hog"; s2 = "Horse, Cat , Dog, Frog , Log, Hog "; s3 = "Horse\rCat\r Dog\rFrog\rLog \rHog"; s4 = "Horse"; ref = "Horse Cat Dog Frog Log Hog error"; hWP = WordParseCreate(WP_GENERAL, ref); AddMessage("Item Word Space Comma Line None"); AddMessage("---- ------- ----- ----- ----- -----"); ix = 0; s5 = WordParseGetWord(hWP); while (s5 != "") { i1 = ScanString(s1, s5); i2 = ScanString(s2, s5); i3 = ScanString(s3, s5); i4 = ScanString(s4, s5); AddMessage(" %2d %-8s %4d %4d %4d %4d", ++ix, s5, i1, i2, i3, i4); s5 = WordParseGetWord(hWP); }
Note that each s1, s2, s3 contain a different delimiter mode and s4 is a single item. Note that spaces are randomly added to the lists to demonstrate the trimming action. The log result:
Item Word Space Comma Line None ---- ------- ----- ----- ----- ----- 1 Horse 0 0 0 0 2 Cat 1 1 1 -1 3 Dog 2 2 2 -1 4 Frog 3 3 3 -1 5 Log 4 4 4 -1 6 Hog 5 5 5 -1 7 error -1 -1 -1 -1
Related Functions
Platform Support
Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL
Legato IDE, Legato Basic
Page revised 2024-12-13
Table of Contents | < < Previous | Next >> |
© 2012-2024 Novaworks, LLC. All rights reserved worldwide. Unauthorized use, duplication or transmission prohibited by law. Portions of the software are protected by US Patents 10,095,672, 10,706,221 and 11,210,456. GoFiler™ and Legato™ are trademarks of Novaworks, LLC. EDGAR® is a federally registered trademark of the U.S. Securities and Exchange Commission. Novaworks is not affiliated with or approved by the U.S. Securities and Exchange Commission. All other trademarks are property of their respective owners. Use of the features specified in this language are subject to terms, conditions and limitations of the Software License Agreement.