GXSTR class¶
-
class
geosoft.gx.
GXSTR
¶ This library is not a class. Use the STR library functions to work with and manipulate string variables. Since the GX Programming Language does not provide string literal tokens, you must use these functions for any string operations you want to perform.
-
static
char_n
((GXContext)ctx, (str)arg1, (int)arg2, (int)arg3) → int:¶ Returns the ASCII value of the n'th character.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – string
- arg2 (int) – character to get
- arg3 (int) – maximum string length (unused)
Returns: ASCII value of n’th character in string. The first character is 0.
Return type: int
New in version 5.0.0.
- ctx (
-
static
count_tokens
((GXContext)ctx, (str)arg1, (str)arg2) → int:¶ Counts number of tokens.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – string to tokenize
- arg2 (str) – delimiter characters
Returns: Number of tokens in the string.
Return type: int
New in version 5.0.0.
Note:
Delimiters are "soft" in that one or more delimiters is considered a single delimiter, and preceding and trailing delimiters are ignored. DO NOT use this function except in GXC code. The corresponding
geosoft.gx.GXSTR.get_token()
function will not operate correctly in GX.Net code.- ctx (
-
static
escape
((GXContext)ctx, (str_ref)arg1, (int)arg2) → None:¶ Convert/replace escape sequences in strings.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – string to modify - arg2 (int) – STR_ESCAPE constants
Returns: Nothing
Return type: None
New in version 5.0.6.
Note:
Escape characters: a bell b backspace f formfeed n new line r carriage return t tab v vertical tab " quote character x take 'x' literally \ backslash ooo octal up to 3 characters xhh hex up to 2 characters A common use of this function is to convert double-quote characters in a user unput string to " so the string can be placed in a tokenized string.
- ctx (
-
static
file_combine_parts
((GXContext)ctx, (str)arg1, (str)arg2, (str)arg3, (str)arg4, (str)arg5, (str_ref)arg6) → None:¶ Combine file parts to build a file name.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – drive
- arg2 (str) – directory
- arg3 (str) – name
- arg4 (str) – extension
- arg5 (str) – qualifiers
- arg6 (
geosoft.gx.str_ref
) – destination string, can be same as input
Returns: Nothing
Return type: None
New in version 5.0.0.
- ctx (
-
static
file_ext
((GXContext)ctx, (str)arg1, (str)arg2, (str_ref)arg3, (int)arg4) → None:¶ Add a file extension onto a file name string.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – file name to extend
- arg2 (str) – extension if “”, extenstion and ‘.’ are stripped.
- arg3 (
geosoft.gx.str_ref
) – extended file name (can be same as input) - arg4 (int) – FILE_EXT constants
Returns: Nothing
Return type: None
New in version 5.0.0.
- ctx (
-
static
file_name_part
((GXContext)ctx, (str)arg1, (str_ref)arg2, (int)arg3) → None:¶ Get part of a file name.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – file name
- arg2 (
geosoft.gx.str_ref
) – destination string, can be same as input - arg3 (int) – STR_FILE_PART constants
Returns: Nothing
Return type: None
New in version 5.0.0.
- ctx (
-
static
format_crc
((GXContext)ctx, (int)arg1, (str_ref)arg2, (int)arg3) → None:¶ Convert a GX CRC value to a string.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (int) – CRC value to format
- arg2 (
geosoft.gx.str_ref
) – Resulting string - arg3 (int) – Width of the field
Returns: Nothing
Return type: None
New in version 5.0.0.
- ctx (
-
static
format_date
((GXContext)ctx, (float)arg1, (str_ref)arg2, (int)arg3, (int)arg4) → None:¶ Convert a GX real to a date string.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (float) – date value in decimal years to format
- arg2 (
geosoft.gx.str_ref
) – Resulting string - arg3 (int) – Width of the field
- arg4 (int) – DATE_FORMAT constants
Returns: Nothing
Return type: None
New in version 5.0.0.
- ctx (
-
static
format_double
((GXContext)ctx, (float)arg1, (str_ref)arg2, (int)arg3, (int)arg4, (int)arg5) → None:¶ Convert a GX real to a string.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (float) – value to format
- arg2 (
geosoft.gx.str_ref
) – Resulting string - arg3 (int) – GS_FORMATS constants
- arg4 (int) – Width of the field
- arg5 (int) – Significant digits/decimals
Returns: Nothing
Return type: None
New in version 5.0.0.
- ctx (
-
static
format_i
((GXContext)ctx, (int)arg1, (str_ref)arg2, (int)arg3) → None:¶ Convert a GX int to a string.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (int) – value to format
- arg2 (
geosoft.gx.str_ref
) – Resulting string - arg3 (int) – Width of the field
Returns: Nothing
Return type: None
New in version 5.0.0.
- ctx (
-
static
format_r
((GXContext)ctx, (float)arg1, (str_ref)arg2, (int)arg3, (int)arg4) → None:¶ Convert a GX real to a string with significant digits.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (float) – value to format
- arg2 (
geosoft.gx.str_ref
) – Resulting string - arg3 (int) – Width of the field
- arg4 (int) – Significant digits
Returns: Nothing
Return type: None
New in version 5.0.0.
- ctx (
-
static
format_r2
((GXContext)ctx, (float)arg1, (str_ref)arg2, (int)arg3, (int)arg4) → None:¶ Convert a GX real to a string with given decimals.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (float) – value to format
- arg2 (
geosoft.gx.str_ref
) – Resulting string - arg3 (int) – Width of the field
- arg4 (int) – Decimals
Returns: Nothing
Return type: None
New in version 5.0.0.
- ctx (
-
static
format_time
((GXContext)ctx, (float)arg1, (str_ref)arg2, (int)arg3, (int)arg4, (int)arg5) → None:¶ Convert a GX real to a time string.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (float) – time value in decimal hours to format
- arg2 (
geosoft.gx.str_ref
) – Resulting string - arg3 (int) – Width of the field
- arg4 (int) – Decimals to format with
- arg5 (int) – TIME_FORMAT constants
Returns: Nothing
Return type: None
New in version 5.0.0.
- ctx (
-
static
gen_group_name
((GXContext)ctx, (str)arg1, (str)arg2, (str)arg3, (str_ref)arg4) → None:¶ Generate a group name string from type string, database and channel(optional) strings..
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – input type string (static part)
- arg2 (str) – input db string
- arg3 (str) – input ch string (could be 0 length)
- arg4 (
geosoft.gx.str_ref
) – output group name string
Returns: Nothing
Return type: None
New in version 5.1.4.
Note:
The output group name string is formed in the way of typestr_dbstr_chstr. If the database/channel strings is too long to fit the output string (max total length of 1040, including the NULL ending), then the typestr will always be kept the full length to be the first part, while the dbstr and/or chstr will be shortened to be the second and/or third part of the output string.
See also
GenNewGroupName_MVIEW
- ctx (
-
static
get_char
((GXContext)ctx, (str)arg1) → int:¶ Returns the ASCII value of a character.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – string to return ascii value of first character
Returns: ASCII value of first character in string.
Return type: int
New in version 5.0.0.
- ctx (
-
static
get_m_file
((GXContext)ctx, (str)arg1, (str_ref)arg2, (int)arg3) → None:¶ Get the indexed filepath from a multiple filepath string
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – input multifile string
- arg2 (
geosoft.gx.str_ref
) – output filepath string - arg3 (int) – index of file
Returns: Nothing
Return type: None
New in version 5.0.0.
Note:
The multifile string must use '|' as a delimiter. Do not pass a string after calling
geosoft.gx.GXSTR.tokenize()
.- ctx (
-
static
get_token
((GXContext)ctx, (str_ref)arg1, (str)arg2, (int)arg3) → None:¶ Get a token from a tokenized string.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – destination string - arg2 (str) – tokenized string
- arg3 (int) – token number wanted (0 is the first!)
Returns: Nothing
Return type: None
New in version 5.0.0.
Note:
Call
geosoft.gx.GXSTR.tokens()
to prepare the tokenized string. You MUST NOT get tokens beyond number of tokens returned bygeosoft.gx.GXSTR.tokens()
orgeosoft.gx.GXSTR.tokens2()
. The first token has index 0. DO NOT use this function except in GXC code.geosoft.gx.GXSTR.get_token()
function will not operate correctly in GX.Net code.See also
geosoft.gx.GXSTR.tokens()
, GetToken_STR- ctx (
-
static
justify
((GXContext)ctx, (str)arg1, (str_ref)arg2, (int)arg3, (int)arg4) → None:¶ Justify a string
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – string to justify
- arg2 (
geosoft.gx.str_ref
) – result string, can be same as input - arg3 (int) – justification width
- arg4 (int) – STR_JUSTIFY constants
Returns: Nothing
Return type: None
New in version 5.0.0.
Note:
If the string is too big to fit in the number of display characters, the output string will be "**" justified as specified.
- ctx (
-
static
make_alpha
((GXContext)ctx, (str_ref)arg1) → None:¶ Turns all non alpha-numeric characters into an _.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – String to trim
Returns: Nothing
Return type: None
New in version 5.1.8.
Note:
THE STRING IS MODIFIED.
- ctx (
-
static
parse_list
((GXContext)ctx, (str)arg1, (GXVV)arg2) → None:¶ Parse a tokenized list to get a selection list.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – String to be parsed
- arg2 (
geosoft.gx.GXVV
) – Selection Buffer to fill
Returns: Nothing
Return type: None
New in version 5.0.1.
Note:
Given a list such as "1,3,4,6-9,12", it fills the input buffer with 1 if the number is selected, 0 if not. The items are delimited with spaces or commas, and ranges are acceptable, either using a "-" or ":", e.g. 3-6 and 3:6 both mean 3,4,5, and 6. Only values from 0 to one less than the buffer length are used. Out-of-range values are ignored.
- ctx (
-
static
printf
((GXContext)ctx, (str_ref)arg1, (str)arg2) → None:¶ Variable Argument PrintF function
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – destination string - arg2 (str) – pattern string
Returns: Nothing
Return type: None
New in version 7.3.0.
- ctx (
-
static
remove_qualifiers
((GXContext)ctx, (str)arg1, (str_ref)arg2) → None:¶ Remove file qualifiers from a file name
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – input file name
- arg2 (
geosoft.gx.str_ref
) – output file name (can be same as input)
Returns: Nothing
Return type: None
New in version 7.0.1.
- ctx (
-
static
replace_char
((GXContext)ctx, (str_ref)arg1, (str)arg2, (str)arg3) → None:¶ Replaces characters in a string.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – string to modify - arg2 (str) – character to replace (first character only)
- arg3 (str) – replacement character (first character only)
Returns: Nothing
Return type: None
New in version 5.0.0.
Note:
If the input replacement character is "", then the string will be truncated at the first character to replace.
- ctx (
-
static
replace_char2
((GXContext)ctx, (str_ref)arg1, (str)arg2, (str)arg3) → None:¶ Replaces characters in a string, supports simple removal.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – string to modify - arg2 (str) – character to replace (first character only)
- arg3 (str) – replacement character (first character only)
Returns: Nothing
Return type: None
New in version 6.3.0.
Note:
If the replacement character is "" (NULL character) then the character to replace is removed from the input string, and the string is shortened.
- ctx (
-
static
replace_match_string
((GXContext)ctx, (str_ref)arg1, (str)arg2, (str)arg3) → None:¶ Replaces all occurances of match string by replacement string with case sensitive.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – Destination String - arg2 (str) – match string to replace
- arg3 (str) – replacement string
Returns: Nothing
Return type: None
New in version 7.0.1.
Note:
If the replacement string is "" (NULL character) then the string to replace is removed from the input string, and the string is shortened.
- ctx (
-
static
replace_multi_char
((GXContext)ctx, (str_ref)arg1, (str)arg2, (str)arg3) → None:¶ Replaces multiple characters in a string.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – string to modify - arg2 (str) – characters to replace
- arg3 (str) – replacement characters
Returns: Nothing
Return type: None
New in version 5.1.5.
Note:
The number of characters to replace must equal the number of replacement characters.
- ctx (
-
static
replace_non_ascii
((GXContext)ctx, (str_ref)arg1, (str)arg2) → None:¶ Replace non-ASCII characters in a string.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – string to modify - arg2 (str) – replacement character
Returns: Nothing
Return type: None
New in version 6.0.0.
Note:
All characthers > 127 will be replaced by the first character of the replacement string.
- ctx (
-
static
replacei_match_string
((GXContext)ctx, (str_ref)arg1, (str)arg2, (str)arg3) → None:¶ Replaces all occurances of match string by replacement string with case insensitive.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – Destination String - arg2 (str) – match string to replace
- arg3 (str) – replacement string
Returns: Nothing
Return type: None
New in version 7.0.1.
Note:
If the replacement string is "" (NULL character) then the string to replace is removed from the input string, and the string is shortened.
- ctx (
-
static
scan_date
((GXContext)ctx, (str)arg1, (int)arg2) → float:¶ Convert a date string to a GX real.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – Date string
- arg2 (int) – DATE_FORMAT constants
Returns: Resulting Real, rDUMMY if conversion fails.
Return type: float
New in version 6.0.1.
Note:
OLD usage, use ScanForm_STR instead.
- ctx (
-
static
scan_form
((GXContext)ctx, (str)arg1, (int)arg2) → float:¶ Convert a formated string to a real.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – Date string
- arg2 (int) – GS_FORMATS constants
Returns: Resulting Real, rDUMMY if conversion fails.
Return type: float
New in version 6.0.1.
- ctx (
-
static
scan_i
((GXContext)ctx, (str)arg1) → int:¶ Convert a string to a GX int.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – String to convert to an integer
Returns: Resulting Integer, iDUMMY is bad integer
Return type: int
New in version 6.0.1.
- ctx (
-
static
scan_r
((GXContext)ctx, (str)arg1) → float:¶ Convert a string to a GX real.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – String to convert to a real
Returns: Resulting Real, rDUMMY if bad string.
Return type: float
New in version 6.0.1.
- ctx (
-
static
scan_time
((GXContext)ctx, (str)arg1, (int)arg2) → float:¶ Convert a time string to a GX real.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – Date string
- arg2 (int) – TIME_FORMAT constants
Returns: Resulting Real, rDUMMY if conversion fails.
Return type: float
New in version 6.0.1.
Note:
OLD usage, use ScanForm_STR instead.
- ctx (
-
static
set_char
((GXContext)ctx, (str_ref)arg1, (int)arg2) → None:¶ Set a string's first character using an ASCII value of a character.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – string - arg2 (int) – ASCII value
Returns: Nothing
Return type: None
New in version 5.1.4.
- ctx (
-
static
set_char_n
((GXContext)ctx, (str_ref)arg1, (int)arg2, (int)arg3) → None:¶ Set the n'th character of a string using an ASCII value
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – string - arg2 (int) – character to set
- arg3 (int) – ASCII value
Returns: Nothing
Return type: None
New in version 5.1.4.
- ctx (
-
static
split_string
((GXContext)ctx, (str_ref)arg1, (str)arg2, (str_ref)arg3) → None:¶ Splits a string in two on a character.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – original string - arg2 (str) – split character (first character of string)
- arg3 (
geosoft.gx.str_ref
) – split string past split character.
Returns: Nothing
Return type: None
New in version 5.0.0.
Note:
The original string is modified by terminating it at the character split. The part of the string past the character split is copied to the split string. Split characters in quoted strings are ignored. This function is mainly intended to separate comments from control file strings.
- ctx (
-
static
str_mask
((GXContext)ctx, (str)arg1, (str)arg2) → int:¶ Case sensitive comparison of two strings.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – mask
- arg2 (str) – string to test
Returns: 0 if string does not match mask. 1 if string matches mask.
Return type: int
New in version 5.0.0.
Note:
Mask characters '*' - matches any one or more up to next character '?' - matches one character Test is case sensitive
- ctx (
-
static
str_min
((GXContext)ctx, (str_ref)arg1) → int:¶ Remove spaces and tabs and return length
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – string to find the min length of
Returns: String length.
Return type: int
New in version 5.0.0.
Note:
String may be modified. This function should not be used to determine if a file name string is defined, because a valid file name can contain spaces, and once "tested" the name will be altered. Instead, use
geosoft.gx.GXSTR.str_min2()
, or usegeosoft.gx.GXSYS.file_exist()
to see if the file actually exists.- ctx (
-
static
str_min2
((GXContext)ctx, (str)arg1) → int:¶ Length less spaces and tabs, string unchanged.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – string to find the min length of
Returns: String length.
Return type: int
New in version 5.0.0.
- ctx (
-
static
str_str
((GXContext)ctx, (str)arg1, (str)arg2, (int)arg3) → int:¶ Scan a string for the occurrence of a given substring.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – string to scan
- arg2 (str) – string to look for
- arg3 (int) – STR_CASE constants
Returns: -1 if the substring does not occur in the string Index of first matching location if found
Return type: int
New in version 5.1.6.
- ctx (
-
static
strcat
((GXContext)ctx, (str_ref)arg1, (str)arg2) → None:¶ This method contatinates a string.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – Destination String - arg2 (str) – String to add
Returns: Nothing
Return type: None
New in version 5.0.0.
- ctx (
-
static
strcmp
((GXContext)ctx, (str)arg1, (str)arg2, (int)arg3) → int:¶ This method compares two strings and returns these values
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – string A
- arg2 (str) – string B
- arg3 (int) – STR_CASE constants
Returns: A < B -1 A == B 0 A > B 1
Return type: int
New in version 5.0.0.
- ctx (
-
static
strcpy
((GXContext)ctx, (str_ref)arg1, (str)arg2) → None:¶ This method copies a string into another string.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – destination string - arg2 (str) – origin string
Returns: Nothing
Return type: None
New in version 5.0.0.
- ctx (
-
static
stri_mask
((GXContext)ctx, (str)arg1, (str)arg2) → int:¶ Case insensitive comparison of two strings.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – mask
- arg2 (str) – string to test
Returns: 0 if string does not match mask. 1 if string matches mask.
Return type: int
New in version 5.0.0.
Note:
Mask characters '*' - matches any one or more up to next character '?' - matches one character Test is case insensitive
- ctx (
-
static
strins
((GXContext)ctx, (str_ref)arg1, (int)arg2, (str)arg3) → None:¶ This method inserts a string at a specified position.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – Destination String - arg2 (int) – Insert Position
- arg3 (str) – String to add
Returns: Nothing
Return type: None
New in version 5.1.8.
Note:
If the specified position does not fall within the current string the source string will simply be Concatenated.
- ctx (
-
static
strlen
((GXContext)ctx, (str)arg1) → int:¶ Returns the length of a string.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – string to find the length of
Returns: String length.
Return type: int
New in version 5.0.0.
- ctx (
-
static
strncmp
((GXContext)ctx, (str)arg1, (str)arg2, (int)arg3, (int)arg4) → int:¶ Compares two strings to a given number of characters.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – string A
- arg2 (str) – string B
- arg3 (int) – number of characters to compare
- arg4 (int) – STR_CASE constants
Returns: A < B -1 A == B 0 A > B 1
Return type: int
New in version 5.0.5.
- ctx (
-
static
substr
((GXContext)ctx, (str_ref)arg1, (str)arg2, (int)arg3, (int)arg4) → None:¶ Extract part of a string.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – destination string - arg2 (str) – origin string
- arg3 (int) – start location
- arg4 (int) – number of characters
Returns: Nothing
Return type: None
New in version 6.2.0.
Note:
The destination string length will be less than the requested length if the substring is not fully enclosed in the origin string.
- ctx (
-
static
to_lower
((GXContext)ctx, (str_ref)arg1) → None:¶ Convert a string to lower case.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – String
Returns: Nothing
Return type: None
New in version 5.0.0.
- ctx (
-
static
to_upper
((GXContext)ctx, (str_ref)arg1) → None:¶ Convert a string to upper case.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – String
Returns: Nothing
Return type: None
New in version 5.0.0.
- ctx (
-
static
tokenize
((GXContext)ctx, (str_ref)arg1, (str)arg2, (str)arg3, (str)arg4, (str)arg5) → int:¶ Tokenize a string based on any characters.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – str - String containing token(s) - arg2 (str) – szSoft - Soft delimiters (spaces/tabs)
- arg3 (str) – szHard - Hard delimiters (commas)
- arg4 (str) – szEsc - Escape delimiters (back-slash)
- arg5 (str) – szQuote- Quote delimiters (quote characters)
Returns: number of tokens
Return type: int
New in version 5.0.0.
Note:
This uses a finite state machine to tokenize on these rules: 1. Any one character following an escape delimiter is treated as a normal character. 2. Any characters inside a quote string are treated as normal characters. 3. Any number of Soft delimiters in sequence without a hard delimiter are treated as one hard delimited. 4. Any number of soft delimiters can preceed or follow a hard delimiter and are ignored. EXAMPLE Soft = [ ] Hard = [,] Escape = [] Quote = ["] [this is a , , the "test," of , ," my delimite fi,] Results in: [this] [is] [a] [] [the] ["test,"] [of] [,"] [my] [delimite] [fi] [] NOT use this function except in GXC code. The corresponding etToken_STR function will not operate correctly in GX.Net code.
See also
GetToken_STR
- ctx (
-
static
tokens
((GXContext)ctx, (str_ref)arg1, (str)arg2) → int:¶ Tokenize a string
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – string to tokenize - arg2 (str) – delimiter characters
Returns: number of tokens, maximum is 2048
Return type: int
New in version 5.0.0.
Note:
Delimiters in the string are reduced to a single NULL. Delimiters withing double quoted strings are ignored. Use GetToken_STR to extract tokens. DO NOT use this function except in GXC code. The corresponding
geosoft.gx.GXSTR.get_token()
function will not operate correctly in GX.Net code.See also
geosoft.gx.GXSTR.tokens2()
, GetToken_STR- ctx (
-
static
tokens2
((GXContext)ctx, (str_ref)arg1, (str)arg2, (str)arg3, (str)arg4, (str)arg5) → int:¶ General tokenize a string
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – string to tokenize - arg2 (str) – szSoft - Soft delimiters (spaces/tabs)
- arg3 (str) – szHard - Hard delimiters (commas)
- arg4 (str) – szEsc - Escape delimiters (back-slash)
- arg5 (str) – szQuote- Quote delimiters (quote characters)
Returns: Number of Tokens
Return type: int
New in version 5.0.0.
Note:
This function is for old GX compatibility only. See
geosoft.gx.GXSTR.tokenize()
. DO NOT use this function except in GXC code. The correspondinggeosoft.gx.GXSTR.get_token()
function will not operate correctly in GX.Net code.- ctx (
-
static
trim_quotes
((GXContext)ctx, (str_ref)arg1) → None:¶ Remove double quotes.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – String to trim
Returns: Nothing
Return type: None
New in version 5.0.0.
Note:
THE STRING IS MODIFIED. This method goes through the string and removes all spaces in a string except those enclosed in quotes. It then removes any quotes. It is usfull for trimming unwanted spaces from an input string but allows the user to use quotes as well. If a quote follows a backslash, the quote is retained and the backslash is deleted. These quotes are NOT treated as delimiters.
- ctx (
-
static
trim_space
((GXContext)ctx, (str_ref)arg1, (int)arg2) → None:¶ Remove leading and/or trailing whitespace.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – String to trim - arg2 (int) – STR_TRIM constants
Returns: Nothing
Return type: None
New in version 5.0.0.
Note:
THE STRING IS MODIFIED. Whitespace characters are defined as space, tab, carriage return, new line, vertical tab or formfeed (0x09 to 0x0D, 0x20)
- ctx (
-
static
un_quote
((GXContext)ctx, (str_ref)arg1) → None:¶ Remove double quotes from string
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (
geosoft.gx.str_ref
) – String to unquote
Returns: Nothing
Return type: None
New in version 5.0.0.
Note:
THE STRING IS MODIFIED. The pointers will be advanced past a first character quote and a last character quote will be set to .0'. Both first and last characters must be quotes for the triming to take place.
- ctx (
-
static
xyz_line
((GXContext)ctx, (str)arg1, (str_ref)arg2) → None:¶ Make a valid XYZ line name from a valid DB line name.
Parameters: - ctx (
geosoft.gx.GXContext
) – The GX execution context - arg1 (str) – line name to convert
- arg2 (
geosoft.gx.str_ref
) – buffer to hold new line name
Returns: Nothing
Return type: None
New in version 5.0.0.
- ctx (
-
static
FILE_EXT constants¶
Extension option
-
gx.
FILE_EXT_ADD_IF_NONE
= 0¶
will add the extension only if no extension is present.
-
gx.
FILE_EXT_FORCE
= 1¶
will cause a renaming of the file extension to the new extension.
STR_ESCAPE constants¶
How to handle escape
-
gx.
ESCAPE_CONVERT
= 0¶
Converts non-standard characters in a string to escape sequences.
-
gx.
ESCAPE_REPLACE
= 1¶
Replaces escape sequences with original characters.
STR_FILE_PART constants¶
Parts of a path string
-
gx.
STR_FILE_PART_NAME
= 0¶
File Name
-
gx.
STR_FILE_PART_EXTENSION
= 1¶
Extension
-
gx.
STR_FILE_PART_DIRECTORY
= 2¶
Directory
-
gx.
STR_FILE_PART_VOLUME
= 3¶
Drive
-
gx.
STR_FILE_PART_QUALIFIERS
= 4¶
Qualifiers
-
gx.
STR_FILE_PART_NAME_EXTENSION
= 5¶
Name and the Extension together
-
gx.
STR_FILE_PART_FULLPATH_NO_QUALIFIERS
= 6¶
Full name of file with no qualifiers