
Description
Returns the number of elements of array variable

Syntax
ret = count(array)

Parameters
| array | : | Array to check the size |

Return Value
| 0 or more | : | Number of elements in an array | |
| -1 | : | Not an array | |

Example
//[result example]
//
// --------------------------------
// a_array[0] => elem1
// a_array[1] => elem2
// a_array[2] => elem3
//
// *** n_count = count(a_array) ***
//
// n_count => 3
// --------------------------------
//
run()
exit(0)
function run()
local a_array = { 'elem1', 'elem2', 'elem3' }
local n_count
local i
print("--------------------------------", stdout)
loop i=0; i<count(a_array); i++
print("a_array[" & i & "] => " & a_array[i], stdout)
endloop
print("\n*** n_count = count(a_array) ***\n", stdout)
// count
n_count = count(a_array)
print("n_count => " & n_count, stdout)
print("--------------------------------", stdout)
endfunction

Description
Joins the separate strings (all elements of ARRAY) into a single string and returns it
You can insert a delimiter (DELIM) between strings.

Syntax
ret = join(delim,array)

Parameters
| delim | : | Delimiter |
| array | : | Array |

Return Value
| NULL | : | Error or associative character string | |
| string | : | Associative character string | |

System Return Value

Example
//[result example]
//
// hello world !!
//
run()
exit
function run()
local output_str
local w_array = {'hello', 'world', '!!'}
output_str = join(" ", w_array)
print(output_str, stdout)
endfunction

Description
Pops and returns the last value from the array variable
Poped element is omitted from the source array and the array is shortened by one element.
The combination of pop and push functions will enable easy implementation of stack mechanism.

Syntax
ret = pop(array)

Parameters
| array | : | Array to pop an element |

Example
//[result example]
//
// --------------------------------
// a_array[0] => elem1
// a_array[1] => elem2
// a_array[2] => elem3
//
// *** s_elem = pop(a_array) ***
//
// a_array[0] => elem1
// a_array[1] => elem2
//
// s_elem => elem3
// --------------------------------
run()
exit(0)
function run()
local a_array = { 'elem1', 'elem2', 'elem3' }
local s_elem
local i
print("--------------------------------", stdout)
loop i=0; i<count(a_array); i++
print("a_array[" & i & "] => " & a_array[i], stdout)
endloop
print("\n*** s_elem = pop(a_array) ***\n", stdout)
// pop
s_elem = pop(a_array)
loop i=0; i<count(a_array); i++
print("a_array[" & i & "] => " & a_array[i], stdout)
endloop
print("", stdout)
print("s_elem => " & s_elem)
print("--------------------------------", stdout)
endfunction

Description
Pushes the value onto the end of array variable
Number of elements in array increases by 1
If non-array variable is specified, the length of the array becomes two elements of which the original element will be 0th element and the pushed element will be the 1st element.
The combination of push and pop functions will enable easy implementation of stack mechanism.

Syntax
ret = push(array,value)

Parameters
| array | : | Array to add an element |
| value | : | Element to be added |

Example
run()
exit(0)
function run()
local a_array = { 'elem1', 'elem2', 'elem3' }
local s_str = 'aaa'
local i
print("[ sample1 ]\n", stdout)
loop i=0; i<count(a_array); i++
print("a_array[" & i & "] => " & a_array[i], stdout)
endloop
print("\n*** push(a_array, 'elem4') ***\n", stdout)
// push
push(a_array, 'elem4')
loop i=0; i<count(a_array); i++
print("a_array[" & i & "] => " & a_array[i], stdout)
endloop
print("\n", stdout)
print("[ sample2 ]\n", stdout)
print("s_str = 'aaa'", stdout)
print("\n*** push(s_str, 'bbb') ***\n", stdout)
// push
push(s_str, 'bbb')
loop i=0; i<count(s_str); i++
print("s_str[" & i & "] => " & s_str[i], stdout)
endloop
print("--------------------------------", stdout)
endfunction

Description
Shifts the first value of the array off and returns it
Shited element is omitted from the source array. The array is shortened by one element and rest of the elements is moved down.
The combination of push and shift will enable easy implementation of FIFO queue.

Syntax
ret = shift(array)

Parameters
| array | : | Array to shift an element |

Example
//[result example]
//
// --------------------------------
// a_array[0] => elem1
// a_array[1] => elem2
// a_array[2] => elem3
//
// *** s_elem = shift(a_array) ***
//
// a_array[0] => elem2
// a_array[1] => elem3
//
// s_elem => elem1
// --------------------------------
//
run()
exit(0)
function run()
local a_array = { 'elem1', 'elem2', 'elem3' }
local s_elem
local i
print("--------------------------------", stdout)
loop i=0; i<count(a_array); i++
print("a_array[" & i & "] => " & a_array[i], stdout)
endloop
print("\n*** s_elem = shift(a_array) ***\n", stdout)
// shift
s_elem = shift(a_array)
loop i=0; i<count(a_array); i++
print("a_array[" & i & "] => " & a_array[i], stdout)
endloop
print("", stdout)
print("s_elem => " & s_elem)
print("--------------------------------", stdout)
endfunction

Description
Sorts array based on the conditions.
Order condistions are as follows:
+ : ascending sort in string comparison order
+ : descending sort in string comparison order
+N : ascending sort in numeric comparison order
+ : descending sort in numeric comparison order
Null character string: No sorting
Multiple arrays can be sorted as a table
In this case, first, all array is sorted in array1. If the value is the same in array1, they will be sorted in array2. This continues in the same manner.
string2 is the order condition for array2.

Syntax
ret = sort(count,string1,array1,string2, array2, { … })

Parameters
| count | : | Number of elements in array |
| string1 | : | Sort condition |
| array1 | : | Array to be sorted |
| string2, array2, { … } | : | Add when multiple arrays are sorted at a time. You can specify multiple sort conditions and arrays as a pair. |

Return Value

System Return Value

Example
//[result example]
//
// 3.000000
// 6.000000
// 9.000000
// 18.000000
// 27.000000
// 100.000000
//
exit Run()
function Run()
local arr[6] = {18, 9, 6, 27, 100, 3}
local sort_arr
local i
sort(6, '+N', arr)
loop i=0; i<count(arr); i++
print('${arr[i]}', stdout)
endloop
endfunction

Description
Splits a string into a list of strings by a specified delimiter and returns the list as array variable.
Multiple delimiters can be specified.

Syntax
ret = split(delim,string)

Parameters
| delim | : | Delimiter |
| string | : | Character string |

Return Value
| 0 | : | Error | |
| array | : | Array of split character strings | |

System Return Value

Example
//[result example]
//
// input words : to be or not to be that is the question
// word[0] : to
// word[1] : be
// word[2] : or
// word[3] : not
// word[4] : to
// word[5] : be
// word[6] : that
// word[7] : is
// word[8] : the
// word[9] : question
//
run()
exit
function run()
local input_str
local w_array, i
input_str = getopt('input words : ')
w_array = split(' ', input_str)
loop i=0; i<count(w_array); i++
print('word[${i}] : ${w_array[i]}', stdout)
endloop
endfunction

Description
Prepend the value into the front of array.
New element will be the 0th element. Number of elements in array increases by 1.
Rest of the elements is moved up.
If non-array variable is specified, the length of the array will be two elements of which the new element will be 0th and the original element if the 1st.
The combination of unshift and pop will enable easy implementation of FIFO queue. .

Syntax
ret = unshift(array,value)

Parameters
| array | : | Array to unshift an element |
| value | : | Element to be added |

Example
//[result example]
//
// --------------------------------
// [ sample1 ]
//
// a_array[0] => elem1
// a_array[1] => elem2
// a_array[2] => elem3
//
// *** unshift(a_array, 'elem0') **
//
// a_array[0] => elem0
// a_array[1] => elem1
// a_array[2] => elem2
// a_array[3] => elem3
//
//
// [ sample2 ]
//
// s_str = 'aaa'
//
// *** unshift(s_str, 'bbb') ***
//
// s_str[0] => bbb
// s_str[1] => aaa
// --------------------------------
//
run()
exit(0)
function run()
local a_array = { 'elem1', 'elem2', 'elem3' }
local s_str = 'aaa'
local i
print("--------------------------------", stdout)
print("[ sample1 ]\n", stdout)
loop i=0; i<count(a_array); i++
print("a_array[" & i & "] => " & a_array[i], stdout)
endloop
print("\n*** unshift(a_array, 'elem0') ***\n", stdout)
// unshift
unshift(a_array, 'elem0')
loop i=0; i<count(a_array); i++
print("a_array[" & i & "] => " & a_array[i], stdout)
endloop
print("\n", stdout)
print("[ sample2 ]\n", stdout)
print("s_str = 'aaa'", stdout)
print("\n*** unshift(s_str, 'bbb') ***\n", stdout)
// unshift
unshift(s_str, 'bbb')
loop i=0; i<count(s_str); i++
print("s_str[" & i & "] => " & s_str[i], stdout)
endloop
print("--------------------------------", stdout)
endfunction