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

Re: [sqr-users] Printing Entire Lookup Table?



Knapp, Richard wrote:

>The SQR lookup is both a table in the database and an array in your
>computer's memory.  The sad part is: you can't access either except
>through the load-lookup command.  It would be more efficient to skip the
>load-lookup, select your pairs from the db using the same logic used to
>load the lookup table and load these into an array that you can traverse
>at will.  Chances are that if your lookup data set is small enough to
>print at the end of the report, the load-lookup mechanism is not an
>efficient way to do the lookup anyway.  (Just guessing here about the
>size of the lookup table/array.)
>  
>
I agree with Richard but have one suggestion, build an index string for 
finding the values.  Basically, take the size of your key and use that 
to pad the key to the max length and add a value that cannot appear in 
the key.  I often use \ | or ; to do this.  Then, you find the position 
of the look-up key in the string with the separator concatenated to find 
the array index to use (based on 0).  For example:

let $StateIndexString = 'AL;AK;AZ;'   ! Obviously, continuing for all 50 
values, or you can build this when populating the array

so if you have a key value in $StateCode

let $FindState = rpad($StateCode,2,' ') || ';'
let #StateIndex = instr($StateCode, $StateIndexString) / 3 ! The length 
of the key and separater.  You may have to truncate this number to get 
the index right.

Please forgive me if the code is not perfect, I do not have my 
references here and I no longer work with SQR (such a shame too!) so I 
am not exactly sure of the syntax.

Good luck!
Mac



_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users