Language Reference
Documentation

Language

Objects
Internet Objects

Strlib Object and String Objects

Has Constructor: NO, Can Create Instance: NO
Can Subclass: NO

The strlib is a global object with methods to manipulate string related values. You do not define a strlib object or a new instance. Strlib is a global variable that you can use any time. Attempting to create a new strlib object will result in an error.

All string values in BAXIC are string objects. A string object has the same methods as the intrinsic strlib object. When calling these methods as part of a string object you do not need to pass the string argument since the subject of the action will be the string object itself.

Methods

Soundex
Syntax: Soundex(value as string) as string

Returns the soundex value of a word.

MID
Syntax: StrLib.MID(value as string, start as integer,[length as integer]) as string

Extract a section of a string starting in start of length characters. If you omit the length argument MID will return all of the characters from start to the end of the string.

ReplaceAll
Syntax: StrLib.REPLACEALL(value as string, find as string,replacewith as string) as string
This function returns the string with all the instances of the string find replaced with replacewith. This function is not case sensitive.

Replace
Syntax: StrLib.REPLACE(value as string, find as string,replacewith as string) as string
This function returns the string with the firstinstance of the string find replaced with replacewith. This function is not case sensitive.

Split
Syntax: StrLib.SPLIT(value as string, delimeter as string) as string
Returns an array made up of the fields delimited by the string in delimiter.

Trim/LTrim/RTrim
Syntax: StrLib.Trim(value as string) as string
StrLib.LTrim(value as string) as string
StrLib.RTrim(value as string) as string

Trim removes leading and trailing whitespace from a string. LTrim removes leading whitespace from a string. RTrim removes trailing whitespace from a string.

CountField
Syntax: StrLib.COUNTFIELDS(value as string, delimiter as string) as integer
This function returns the amount of substring in string when separated by delimiter.

i = strlib.countFields("Jose*Joe*Ana*Lourdes","*")

i = "Jose*Joe*Ana*Lourdes".countFields("*")

myStringVariable = "Jose*Joe*Ana*Lourdes"
i = myStringVariable.countFields("*")

If delimiter is "*" then there are 4 substring "Jose", "Joe", "Ana" and "Lourdes" therefore I will be equal to 4.

NthField
Syntax: StrLib.NTHFIELD(value as string, delimiter as string,segement as string) as string
This function returns the substring number segment of string when the string is broken into pieces by delimiter.

s = strlib.nthField("Jose*Joe*Ana*Lourdes","*",2)

If delimiter is "*" then there are 4 substrings "Jose", "Joe", "Ana" and "Lourdes" the above statement will return "Joe" which is the second substring.

InStr
Syntax: StrLib.INSTR([start as string], value as string, find as string) as string
This function returns the position of the first occurrence of find in string starting at start. Zero is returned if not found or if string is empty. Start must be a numeric value starting at 1.

Chr
Syntax: StrLib.CHR(number as integer) as string
This function returns the character associated with the specified character code in number. Number must be a numeric value from 0 to 255.

Asc
Syntax: StrLib.ASC(character as string) as string
This function returns the character code associated with the specified character in character. Character must be a string with one single character.

Str
Syntax: StrLib.STR(number as float) as string
This function returns the number as a string.

Left/Right
Syntax: StrLib.LEFT(value as string, count as integer)
Syntax: StrLib.RIGHT(value as string, count as integer) as string
The function LEFT returns a string that is count characters starting from the left of string. The function RIGHT does the same starting from the right.

Len
Syntax: StrLib.LEN(value as string, ) as string
This function returns the amount of characters in string.

StrComp
Syntax: StrLib.STRCOMP(string1 as string, string2as string ,[mode as integer]) as string
This function compares two strings and returns a value indicating the result.

Mode is an optional value indicating how to compare the strings. If mode is zero or omitted, the comparison is case sensitive. If it’s 1 then is case insensitive.

The results are 0 if both strings are equal, -1 if string1 is less than string2. 1 if string1 is greater than string2.

LCase/Ucase
Syntax: StrLib.LCASE(value as string)
Syntax: StrLib.UCASE(value as string) as string

The function LCASE returns the string converted to lowercase. UCASE does the opposite it returns the uppercase version of string.

Format
Syntax: StrLib.Format(value as float, format as string) as string
This functions returns the value as a string formatted according to format. Value can only be a number. Value is a string composed of the following characters:

#  placeholder for digit if present
0  placeholder for a digit or 0 if not present
.   placeholder for decimal point
,    placeholder for thousands separator
%   display number multiply by 100

( )   display an open or close paren.
+    displays the plus or negative sign of the number
-     displays only the negative sign
e    displays number in scientific format
\ch the character after the backslash is displayed