HP Business BASIC/XL Reference Manual - HP 3000 MPE/iX Computer Systems - Edition 1 (32715-90001)

G- 25
$title 'PROCESS_STRING_ARRAY of ANYPARM_EXAMPLE',page$
{----------------------------------------------------------------------------}
{ procedure process_string_array of anyparm_example }
{----------------------------------------------------------------------------}
procedure process_string_array(
p_actual_param_table : tp_actual_parameter_array;
param_index : integer;
var tstfil : text
);
const
c_2_spaces = ' ';
type
t_pascal_string = string[c_max_str_len];
tp_pascal_string = ^t_pascal_string;
var
array_element_num : integer; { element number in the array of strings }
word_view_index : integer; { index for the word view of p_array_data }
p_pascal_string : tp_pascal_string; { pointer to string in the array }
array_element_word_length : integer; { maximum length of the string }
begin { procedure process_string_array}
writeln( tstfil, 'STRING Array' );
with p_actual_param_table^[param_index].param_address^.p_array_data^,
{ word_view }
p_actual_param_table^[param_index].param_address^.array_descriptor do
{ total_elements }
begin { with}
{-------------------------------------------------------------------------}
{ The maximum length of each string in the array is identical and can be }
{ set to a constant for processing of the array. Since the information }
{ in word_view[0] is in units of bytes and an extra byte is always }
{ reserved at the end of the string, a simple calculation is performed }
{ to convert the 8 bit byte units to the 32 bit word units. }
{-------------------------------------------------------------------------}
array_element_word_length :=
( ( word_view[0] + c_bytes_per_32_bit_word ) div c_bytes_per_32_bit_word )
+ 1 { for maximum length field } + 1 { for actual length field };
{-------------------------------------------------------------------------}
{ The array of strings is stored as an array of 32 bit words. }
{ word_view_index is used to reference each of these words. }
{-------------------------------------------------------------------------}
word_view_index := 1;
for array_element_num := 0 to ( total_elements - 1 ) do
begin { processing individual strings }
{----------------------------------------------------------------------}
{ Move that part of the word_view array that contains the actual }
{ characters of the string into the temp_string. }
{----------------------------------------------------------------------}
$push, type_coercion 'conversion'$
p_pascal_string := addr( word_view[word_view_index] );
$pop$
writeln( tstfil
, c_2_spaces
, array_element_num:3
, c_2_spaces
, p_pascal_string^
);
{----------------------------------------------------------------------}
{ Increment to the index to the next element in the string array. }
{----------------------------------------------------------------------}
word_view_index := word_view_index + array_element_word_length;