[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Dynamic array name



Pragya Chandra,

Nope.  Array names cannot be dynamic.  You'll need to
refer to the array name directly.

If you're clever, you can put your search routine
in an include file and make the array name part
of the procedure name using a #define variable.
Then, you'd include the file 3 times setting the
array name variable before each include.

Otherwise, just write it 3 times.

Ray


[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi..has anyone used dynamic array names in SQR?  I have 3 arrays in my
> program..all keyed by the same field and have  a search routine for the
> array but don't want to write 3 separate search routines..anyway has anyone
> had any success with dynamic arrray names etc..see code below..thanks
>
> begin-SELECT
> P5.CUST_ID
> P5.ADDRESS_SEQ_NUM
> P5.ADDRESS1
> P5.ADDRESS2
> P5.COUNTY
> .
> .
> .
>   Let $Search_cust_id = &P5.CUST_ID
>   Let $Array_name = 'Addr-Info'
>   Do Search-Array
> .
> .
> .
> end-SELECT
>
>
> begin-procedure Search-Array
> Let #result = 0.99 !If a row is found #result will be asigned a whole no.
> Let #j = 0
> While #j <= #max_rows_array   !Loop through the array till a match for the
> cust id is found.
>      show $Array_name
>      Get $Array_cust_id From $Array_Name (#j) CUST_ID
>      If $Array_cust_id = $search_cust_Id
>         Let #result = #j      !Assign the row no to the result and Break the
> while.
>         Break
>      End-if
>      Add 1 to #j
> End-While
>
> If #result = 0.99
>    !Let #result = #max_rows_array  !If no such cust id is found then add it
> to the last one.
>    Let #result = #max_rows_array + 1
>    Let #max_rows_array = #result
>    Put $Search_Cust_id into $Array_name(#result)
> End-if
>
> end-procedure Search-Array
>

----------------------------------------------------------------------
Ray Ontko   rayo@ontko.com   Phone 1.765.935.4283   Fax 1.765.962.9788
Ray Ontko & Co.   Software Consulting Services   http://www.ontko.com/