Variable-length Arrays Library
Elements of variable length and multiple data types;
2-dimensional arrays, conversion functions
Notes: Since I couldn't decide how many bytes to use for the length
of each element, I made it user-definable (1-4 bytes). This lets
you control how much space you need (the delimited-list functions
are pre-set to use 2 bytes; thousands of characters per element).
- Already Coded:
- NUM_H003(STR code) -- halfway between NUM_WORD and NUM_LONG
- STR_H003(INT num) -- halfway between STR_WORD and STR_LONG
- VLA_DIM(INT rows, INT cols, INT bytes) -- create a new array
bytes for data length: 1=BYTE, 2=WORD, 3=H003, 4=LONG
- VLA_ROWS(STR array) -- return # of rows in array
- VLA_COLS(STR array) -- return # of columns in array
- VLA_ELEM(STR array, INT row, INT col) -- convert row/column
subscripts to element index
- VLA_LEN(STR array) -- return # of elements in array (rows * cols)
- IS_NUMSTR(STR data) -- true if *entire* string coercible to number
- VLA_GET(STR array, INT index, INT what) -- return element property
0=value, 1=datatype, -1=datalen
- VLA_SET(STR array, INT index, value [, STR type]) -- modify value
of an array element (optionally force data type, such as num to str)
- LINE_PARSE(STR list, INT index) -- return specified line from
CR-delimited list
- OCCURS(STR find, STR within) -- return # of occurrences
- TAB_PARSE(STR line, INT index [, INT total]) -- return specified item
from tab-delimited line
- VLA_LISTR(STR list) -- read tab/CR-delimited list to array
- VLA_LISTW(STR array) -- write tab/CR-delimited list from array
- VLA_TRANSPOSE(STR array) -- swap rows/columns
- VLA_INFO(STR array) -- return tab-delimited info about array elements
(common datatype, length of longest element, length of shortest element)
- VLA_GSR(STR gsarray, INT orient) -- read GS-array (GS = Greg Schaefer)
(orient: 0=rows, 1=columns)
- VLA_GSW(STR array) -- write GS-array
- Remaining to do:
- VLA_INS (STR array, INT index, INT count) -- insert element(s) at index
(maybe insert entire rows or columns?)
- VLA_DEL (STR array, INT index, INT count) -- delete element(s) at index
(maybe delete entire rows or columns?)
- VLA_SCAN (STR array, value, INT beg_idx, INT end_idx) -- get element
index of value (0 if not found)
- VLA_SLICE (STR array, INT row, INT col) -- get sub-array, entire row or col
- VLA_DICE (STR array, INT beg_idx, INT end_idx) -- get sub-array of elements
VLA_MID (STR array, INT beg_idx, INT end_idx) -- extract range from array
### dice and mid are same; deciding on name (suggestions welcome!) ###
- VLA_CAT (STR array1, STR array2, INT orient) -- concatenate two arrays
- Wondering about:
- VLA_REDIM (STR array, INT rows, INT cols) -- lengthen or shorten existing
array (is it needed if I have VLA_INS and VLA_DEL?)
- VLA_WEAVE (STR array1, STR array2) -- splice arrays together
- VLA_???? -- Tell me what you need...
(wik, April 16, 1997)