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

Re Comparing array element -Reply



Hi Tai,

I think your element variables are out of sync.  You are
incrementing a varaible (#arr_idx) that is not in your test for
the while loop (#j).

  I know one of the ways we do this is the following:

  size={size}

  while #j < {size}
     if camp_code(#j) = $cmp_code
       array-add   1  2   3    to camp_array(#arr_idx)
              camp_cnt(0) camp_cnt(1) camp_cnt(2)
       let #j = {size}
     else
       add 1 to #j
     end-if
  end-while


>>> Tai Luong <tluong@CCSF.CC.CA.US> 02/03/97
05:15pm >>>
Hi all,

Would somebody tell me how to compare an array element
with a variable. I have created and loaded the following array,
but when I try to compare an array element with the following
code
SQR gives me an error. Any help will be greatly appreciated!

  Create-Array
    Name=camp_array
    Size=20
    Field=camp_code:char:1
    Field=camp_desc:char:20
    Field=camp_cnt:number:3=0

  move 0 to #j
  while camp_code(#j) not = $cmp_code and (#j < 19 )
    add  1  to #arr_idx
  end-while

  if camp_code(#j) = $cmp_code
    array-add   1  2   3    to camp_array(#arr_idx)
           camp_cnt(0) camp_cnt(1) camp_cnt(2)
  end-if

                     Tai Luong, Programmer/Analyst
City College of San Francisco             Voice: 415-452-5050
50 Phelan Avenue, room LB-2                 Fax: 415-239-3919
San Francisco, CA 94112                  E-mail:
tluong@hills.ccsf.cc.ca.us