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

Re: dynamic variables question



> I know one way to efficiently handle this is to use arrays, but I don't
> like messing with arrays.  Then I though 'dynamic variables', but that
> doesn't seem to be working.  If I can get dynamic variables to work I
> can replace the 40+ iterations of the above code with only one.  Here's
> what I have in testing :
>
> while #counter < #max_counter  ! first code line
>   let $number = edit(#counter, '99') ! second code line
>   let $test_var = '$'||$number||'_paid_amount' ! 3rd
>   let [$test_var] = edit(#some_variable, '99999999999') ! 4th
> end-while ! 5th
>
[...]
> I am using sqr v4.1 when I run this.  Any ideas?  Is this something that
> is not allowed, or am I getting something wrong in the syntax?

This is not allowed.  The "[...]" syntax is used for dynamic *SQL*;
it is interpreted when SQR, as your report is running, tries to build the
SQL command strings which are then sent to the database engine.  (In other
words, the dynamic syntax is allowed only in begin-sql and begin-select
paragraphs.)

You are trying to make your actual SQR code dynamic.  Since the SQR code
gets compiled before it is executed (and since it can't change after it has
been compiled), there's no way to have the same line of SQR do different
things each time it is executed.

I'd say you should just use arrays... :)



                                        Nathan
----------------------------------------------------------------------------
Nathan Treadway    | Ray Ontko & Co. | Software consulting services
nathant@ontko.com  | Richmond, IN    | http://www.ontko.com/