Multivalue Functions |
![]() ![]() ![]() |
The QMBasic language has many functions that provide multivalued equivalents of their more commonly used single valued counterparts. In each case, these work element by element through the dynamic arrays passed into the functions, performing the operation on each element in turn to produce an equivalent dynamic array of results.
For example, if we have two dynamic arrays
and
We can concatenate these two dynamic arrays in two ways:
C = A : B sets C to ABCFMDEFFMGHI123FM456FM789 C = CATS(A, B) sets C to ABC123FMDEF456FMGHI789
The main multivalued string functions are
There are also a number of multivalued logical functions. These provide equivalents to the relational operators and other functions that return boolean values.
For example, the GTS(arr1, arr2) function takes two dynamic arrays and returns a new dynamic array of true / false values indicating whether the corresponding elements of arr1 are greater than those of arr2.
C = GTS(A, B)
Returns C as 0FM0VM1VM1FM0
The multi-valued logical functions are
The IFS() function returns a dynamic array constructed from elements chosen from two other dynamic arrays depending on the content of a third dynamic array.
IFS(control.array, true.array, false.array)
where
The IFS() function examines successive elements of control.array and constructs a result array where elements are selected from the corresponding elements of either true.array or false.array depending on the control.array value.
Example
A contains 1VM0VM0VM1VM1VM1VM0 B contains 6VM2VM3VM4VM9VM6VM3 C contains 2VM8VM5VM0VM3VM1VM3
D = IFS(A, B, C)
D now contains 6VM8VM5VM4VM9VM6VM3 |