Previous: From Strings to Characters, Up: Basic Editing [Contents][Index]
Arrays are collections of homogeneous data organized in a sequence.
We have already seen (briefly) arrays of bytes, which use the type
Similarly, it is possible to arrange characters (which are basically little numbers) in an array, like in:
(poke) ['a','b','c'] [0x61UB,0x62UB,0x63UB]
However, the array above is not equivalent to the string
"abc". The later is a simple value, whereas an array is a
composite value, and also is implicitly terminated with a NULL
character, i.e. a 0 byte.
The Poke standard library provides a couple of utility functions to
convert between string values and character arrays:
catos gets an array of characters and returns an equivalent
string. For example:
(poke) catos (['a','b','c']) "abc"
stoca gets a string and an array and sets the element of the
array to the characters composing the string. For example:
(poke) var a = char() (poke) stoca ("abc", a) (poke) a [0x61UB,0x62UB,0x63UB]