Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
/***********************************************************************************************/
/* Set up a TEST stem and add some initial data */
/***********************************************************************************************/
test. = ''
test.1 = 'Fred'
test.2 = 'jim'
test.0 = 2
/***********************************************************************************************/
/* Display the initial contents */
/***********************************************************************************************/
do i = 1 to test.0
say 'Test.'i '=' test.i
end
say
/***********************************************************************************************/
/* Set up a TEST stem and add some initial data */
/***********************************************************************************************/
trial. = ''
trial.1 = 'Jane'
trial.2 = 'Freda'
trial.0 = 2
/***********************************************************************************************/
/* Display the initial contents */
/***********************************************************************************************/
do i = 1 to trial.0
say 'Trial.'i '=' trial.i
end
say
/***********************************************************************************************/
/* Now add extra data to the stem and re-display its contents */
/***********************************************************************************************/
TempData = 'Charlie'
call AddToArray 'test. TempData'
TempData = 'Arthur'
call AddToArray 'test. TempData'
do i = 1 to test.0
say 'Test.'i '=' test.i
end
say
/***********************************************************************************************/
/* Now add extra data to the stem and re-display its contents */
/***********************************************************************************************/
TempData = 'Annabelle'
call AddToArray 'trial. TempData'
TempData = 'Sheila'
call AddToArray 'trial. TempData'
do i = 1 to trial.0
say 'Trial.'i '=' trial.i
end
say
return
/*==============[ Pass the array name in as a string and the value to be assigned ]===============*/
AddToArray:
/***********************************************************************************************/
/* Arguments must not have comma separators. */
/* Data to be stored must be in a variable. */
/* The call must be of the form AddToArray 'arrayname. data' */
/***********************************************************************************************/
/***********************************************************************************************/
/* The arguments are stored in the special RESULT variable because it is a variable known to */
/* exist and it is safe to borrow it at this point. This entry point is not in a procedure and */
/* therefore can see the common variables so if we used our own variable name it might */
/* conflict with a variable name used elsewhere in the code. The argument variable names are */
/* exposed in the called routine by using the temporary contents of the RESULT variable. */
/***********************************************************************************************/
result = arg(1) /* store args to expose them in procedure */
/***********************************************************************************************/
/* Call the real code to do the job with the passed arguments. By convention we use the same */
/* name as the entry point above prepended with an underscore. */
/***********************************************************************************************/
call _AddToArray arg(1)
return
_AddToArray:
/***********************************************************************************************/
/* Woody's appendStem routine. Append a value to a stem variable; Increment the count stored */
/* in stem.0 */
/***********************************************************************************************/
/***********************************************************************************************/
/* As this is a procedure all variables are localised except the input parameter variables. */
/* The use of underscores in local variable names is a convention not a requirement. */
/***********************************************************************************************/
procedure expose ( result ) /* expose the argument variables */
parse arg _stemname _stemvalue /* separate the arguments */
_num = value(_stemname || '0') + 1 /* increment the index value */
call value _stemname || '0', _num /* assign new index value to 0 element */
call value _stemname || _num, value(_stemvalue) /* assign value to new element */
return