[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Reply to SQR Array Question.
>
> I am having some difficulty with creating procedures to handle
> my simple array operations, before I even get to the tough ones.
>
> I am using the following INSERT procedure(function) for the array.
>
> BEGIN-PROCEDURE INSERT_ARRAY(#pidm, $deli_code, $rec_type, #position, :#status)
>
> if #position >= {array_size}
> move 0 to #status
> else
> move 1 to #status
> put #pidm into deli_array(#position) deli_array_pidm
> put $deli_code into deli_array(#position) deli_array_deli_code
> put $rec_type into deli_array(#position) deli_array_rec_type
> get #pidm_1, $deli_code_1, $rec_type_1, $err_flg_1 from deli_array(#positio
> show (+1,1) #pidm_1 ' ' $deli_code_1 ' ' $rec_type_1 ' ' $err_flg_1 ' - ' #
> end-if
>
> END-PROCEDURE INSERT_ARRAY
>
> The array is Global, the procedure is local. Therefore I can not
> insert into the array. I am using 2.11, 2.27, and 2.42 versions of SQR.
> How do I tell the procedure that the array I want to insert into is
> a global array? I can access all other global vars with the $_, #_, and &_.
> Does some prefix for the array exist?
>
> And as a curious side note, why does SQR acknowledge the existence
> of the array in the local procedure? It doesn't say the array doesn't exist,
> within the local procedure, eventhough for all uses it doesn't! I would
> think that if the compiler took the time to decide that the procedure
> could not insert into the global array that it would be a logical progression
> to state that it was an error.
>
> I have wore the binding out of my programming manual, and could not
> find any refrences to dealing with arrays on a global/local basis. I have
> also tried to recreate the array within the local procedure, since it is
> not seeing the global array, and I get a duplicate array created error,
> so I know that SQR sees the global array inside the local procedure.
>
> Help!
>
> Thanks in advance,
> Scott...
> ************************************************************
> * Programmer / Analyst | Internet: maysa@oneonta.edu *
> * SICAS Center | SUNY Oneonta *
> * | Lee Hall *
> * | Oneonta, NY 13820 *
> ************************************************************
>
Scott,
I needed to do the same type of things, ie: global arrays, local
procedures to manipulate them, and wrote a small test program to prove
the concept before continuing. Since you didn't include all your source
code, there may be something you did (or didn't do!?!) in calling the
procedures that affected your results. The sample program attached
will execute under SQR 2.4.2 and demonstrates:
1) creating a global array
2) inserting into it from a local procedure being passed the array index
and data to insert
3) getting and displaying data from the array within a local procedure
being passed the array index
Hope this helps!
------------------------------------------------------------------------------
John Griffin (205) 890-2401 | A TTTTTTT SSSSS
Advanced Technology Systems (ATS), Inc. | A A T S
4801 University Square, Suite 2 | AaaaA T SSSSS
Huntsville, AL 35816-3431 | A A T S
johng@rmf41.usace.army.mil | A A T SSSSS
------------------------------------------------------------------------------
Body-Part: 2; Text ------------------------------------------------------
begin-report
do test-loc-array
end-report
begin-procedure test-loc-array
create-array name=dummy size=10 field=a-field:char
move 0 to #i
move 'xxx' to $char-str
do insert-array($char-str,#i)
do display-array(#i)
end-procedure
begin-procedure insert-array($char-string,#index)
put $char-string into dummy(#index) a-field
end-procedure
begin-procedure display-array(#indx)
display #indx 99
get $a-string from dummy(#indx) a-field
display 'contents of array ' noline
display $a-string
end-procedure