Scripting in StreamServe > StreamServe scripting language specifics > Array variables > Example of array usage

Example of array usage
This script is an example on how to builds arrays. The following variables are used:
$ca_no_dialled – at the time the script is called, this variable contains a phone number from a field in a phone bill.
$ca_call_charge – contains the amount charged for the corresponding call.
$arrtele – the array containing phone numbers.
$arramt – the corresponding array of summed costs for calls placed to the phone number.
$totalcharge – a sum that starts out empty and gets $ca_call_charge added to it each time the script is run. It ends up a sum of all the call charges in the phone bill.
$subtotalcharge – a similar sum, but it is read and reset to 0 every now and then (each page) by a different script.
 
//Add charge for this call to sum.
$totalcharge = $totalcharge + $ca_call_charge;
//Add charge for this call to subtotal.
$subtotalcharge = $subtotalcharge + $ca_call_charge;
// See if the current phone number is already in the array of phone numbers.
$retno = FindInArray($arrtele, $ca_no_dialled);
if($retno = "-1") // If -1, then the phone number is a new one.
{
// Determine current size of array, so that we know where to append.
$retsize = ArraySize($arrtele);
/* Add the new phone number to our phone numbers array, and put the corresponding cost in the $arramt array.*/
$arrtele[$retsize] = $ca_no_dialled; // The new phone number
$arramt[$retsize] = $ca_call_charge; // amount charged
}
else
/* The current phone number was found in the array. Add the amount charged to the corresponding $arramt element.*/
$arramt[$retno] = $arramt[$retno] + $ca_call_charge;
OpenText StreamServe 5.6 Updated: 2013-03-01