Xbasic

a5_array_from_string Function

Syntax

Size as N = a5_array_from_string(array_name as C, string as C, scope as P)

Arguments

array_nameCharacter

The name of the array. Eg, "myArr"

stringCharacter

A CR-LF delimited list of items to put in the array.

scopePointer

The scope in which the array is created. Pass in local_variables() to create the array in the local scope. Pass in global_variables() to create the array in the global scope. Pass in your own dot variable to add the array to the variable.

Returns

SizeNumeric

Returns the size of the array.

Description

Creates a character array from a cr-lf delimited string. Returns the size of the array.

Examples: Creating an Array in the Local Scope

dim array_name as c = "myArray"
dim items as c =<<%str%
North
South
East
West
%str%

dim len as n = a5_array_from_string(array_name, items, local_variables())

? len
= 4

? myArray
= [1] = "North"
[2] = "South"
[3] = "East"
[4] = "West"

Example: Creating an Array as a Member of a Dot Variable

dim array_name as c = "numArr"
dim items as c =<<%str%
1
2
3
4
5
6
7
8
9
10
%str%

dim pObj as P

dim len as n = a5_array_from_string(array_name, items, pObj)

? len
= 10

? numArr
ERROR: Variable "numArr" not found.

? pObj.numArr
= [1] = "1"
[2] = "2"
[3] = "3"
[4] = "4"
[5] = "5"
[6] = "6"
[7] = "7"
[8] = "8"
[9] = "9"
[10] = "10"

See Also