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

dynamic variables question



Hello all,

I have an sqr, and I am trying to save some bytes within it.  The
following is a snippet of the code :

if #REMITLINES = 2
  LET $2B_INVOICE_ID        = $OB_INVOICE_ID
  LET $2INVOICE_DT          = $OB_PAY_DOC_DT
  LET $2B_VOUCHER_ID        = $OB_VOUCHER_ID
  LET $2B_PAID_AMT          = $OB_PAID_AMT
  LET $2B_PAID_AMT_GROSS    = $OB_PAID_AMT_GROSS
  LET $2B_DISCOUNT_TAKEN    = $OB_DISCOUNT_TAKEN
  LET #X_PAID_AMT           = #OX_PAID_AMT
  LET $2B_PYMNT_MESSAGE     = $OB_PYMNT_MESSAGE

  LET $2B_INVOICE_ID        = RPAD($2B_INVOICE_ID, 16,' ')
  LET $2B_VOUCHER_ID        = RTRIM($2B_VOUCHER_ID,' ')

  LET #PGSUB_PAID_AMT_GROSS = #PGSUB_PAID_AMT_GROSS + #X_PAID_AMT_GROSS
  LET #PGSUB_DISCOUNT_TAKEN = #PGSUB_DISCOUNT_TAKEN + #X_DISCOUNT_TAKEN
  LET #PGSUB_PAID_AMT       = #PGSUB_PAID_AMT       + #X_PAID_AMT

  END-IF

I have this *40* times in the program, with more examples just like it.
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

When I place a show statement within the code, $test_var does =
$1_paid_amount (for the first one), like it should, but I get the
following error on the 3rd line of code:
Error on line 3:
   (SQR 4000) Result #variable or $variable or '=' missing in
expression.
      let [$test_var] = edit(#some_variable, '99999999999')

Errors were found in the program file.

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?

clark


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com