Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.4j

Application v 5.22b

  

 

Chapter FiveGeneral Functions (continued)

GetNthWord Function

Overview

The GetNthWord function retrieves a single word or item at a specified position.

Syntax/Parameters

Syntax

string  = GetNthWord ( string data,  [int position], [dword flags] );

wstring = GetNthWord ( wstring data, [int position], [dword flags] );

Parameters

data

A string or wstring specifying the source data. The source type dictates the return type.

position

An optional int specifying the zero-based nth word position to retrieve. If omitted, the position is set to 0 for the first word.

flags

An optional dword specifying the parse options. If omitted, the value is WP_GENERAL. The flag values are as follows.

  WP_GENERAL 0 General – stops on word spaces.
  WP_SGML_TAG 1 Tags – stops on tags (SGML, HTML, and XML).
  WP_PROGRAM 2 Program – stops on typical programmatic expressions.
  WP_PROGRAM_GROUP 3 Program Groups – same as mode 2 but returns complete groups for parenthesis (‘( )’), brackets (‘[ ]’), single quotes (‘ ' ' ’), and double quotes (‘ " " ’).
  WP_OBJECT_NOTATION 5 Object Notation — Stops on delimiters commonly used on object references such as ‘.’ ‘[‘ and ‘]’.

 

Return Value

Returns a string or wstring containing the word or empty on failure. Use the GetLastError function to retrieve error information. On success, the last error will contain the zero based index to the start of the word retrieved.

Remarks

The GetNthWord functions encapsulates the Word Parse Object and counts to the specified position and then returns the last word, assuming the item was found. If the word list is exhausted, the return value is an empty string.

The internal word buffer is limited to 1024 characters. Should a parsed string item be larger, the function will return empty string with an overflow error in the last error buffer. If the source cannot be controlled, it is best to use the GetLastError function to determine if a word is not available at the position or if an error occurred.

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Legato IDE, Legato Basic

Page revised 2024-04-22