Fallout2 Opcode Playground

Opcodes: 8000-801F, 8020-803F, 8040-805F,
8060-807F, 8080-809F, 80A0-80BF, 80C0-80DF,
80E0-80FF, 8100-811F, 8120-813F, 8140-8155
 
List Opcodes:Used in Fallout 2Named
Known to DecompilerDescribed

Descriptions for 80A0

Opcode80A0, Tokenize
>> subfunction   Tokenize

Author: legacy information

25.06.02 17:11:21

Tokenize

Parses a string to retrieve values stored in the form of a list delimited by a single character.

String Tokenize(String strMainString, String strToken, char cDelimiter);

Parameters

strMainStringString containing substrings and delimiters.
strTokenPrevious substring or 0 for the first substring.
cDelimiterDelimiting character that delimits tokens and substrings.

Return Value

A string value for the substring retrieved.

Returns 0 if token is not found.

NOTE: The script considers the string "0" as equal to the integer 0. Therefore, in order to store values of "0", a special check is required. Add an integer 1" to the beginning of the return value and if it was a string "0", the result will be a string "10". If it was an integer 0, the result will be an integer 1.

Remarks

Parses a string to retrieve values stored in the form of a list delimited by a single character. If a 0 is passed as the second argument, the first substring is returned. Then, if the first substring is passed as the second argument in a subsequent call, the next substring in the list is returned.

NOTE: The list cannot contain identical values using this method of substring retrieval. But there is a workaround described below.

One way in which this function can be used as a list that allows identical values to be stored is to allow a mainstring to contain substrings that are associated with tokens. Each substring and token pair are delimited from others using the delimiter character. An example mainstring could look like the followiing:

"Token1|First Substring|Token2|Second Substring|..."

Here, "Token1" and "Token2" are the tokens, "First Substring" and "Second Substring" are the substrings associated with them respectively, and '|' is the delimiter character. To obtain the second substring, simply pass the entire string as the mainstring, "Token2" as the token, and '|' as the delimiter to the Tokenize function.

Example

// Create the main string

strMainString := "First|Second|Third|";

// Get the 1st substring

strSubString := Tokenize(strMainString, 0, '|');

// Get the 2nd substring using the previously obtained substring

strSubString := Tokenize(strMainString, strSubString, '|');

// Create the main string using tokens

strMainString := "1|First Substring|2|Second Substring|3|Third String|";

// Get the 1st substring using tokens

strSubString := Tokenize(strMainString, 0, '|');

// Get the 3rd substring using tokens

strSubString := Tokenize(strMainString, "3", '|');

© Interplay, from Klingon Academy scripting documentation