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

RE: [sqr-users] FW: compare array-field with a string



Hello !

Many thanks: this was the solution !!
I always did a DISPLAY instead of your special SHOW and didn't saw
the spaces...

kind regards

   Annerose

-----Original Message-----
From: sqr-users-bounces+annerose.martin=hp.com@sqrug.org
[mailto:sqr-users-bounces+annerose.martin=hp.com@sqrug.org]On Behalf Of
the dragon
Sent: Tuesday, April 06, 2004 15:27
To: sqr-users@sqrug.org
Cc: annerose.martin@hp.co
Subject: RE: [sqr-users] FW: compare array-field with a string


Annerose,

Make certain the value you are comparing is always the same *format*...  My 
guess is you're comparing something with extra spaces against something 
without spaces.  Use a show statement before your compare that looks like 
this...

#debugv show 'The array value for [whatever] = |'  $bewdata_descr '|'

I bet you'll see some extra spaces.  If you just do a regular show, such as

#debugv show 'The array value for [whatever] = '  $bewdata_descr

you'll never see the extra spaces, so [Hugo     ] will *look* like [Hugo], 
but the comparrison will fail.

After you see that you have extra spaces, you'll need to remove them with an 
rtrim and/or ltrim

let $bewdata_descr = ltrim(rtrim($bewdata_descr, ' '), ' ')

before you do your compare....

Hope this helps,

Peace
clark 'the dragon' willis


PSA: Salary <> Slavery.  If you earn a salary, your employer is renting your 
services for 40 hours a week, not purchasing your soul.  Your time is the 
only real finite asset that you have, and once used it can never be 
recovered, so don't waste it by giving it away.

"Time is the coin of your life. It is the only coin you have, and only you 
can determine how it will be spent.  Be careful lest you let other people 
spend it for you."

Carl Sandburg
(1878 - 1967)

----Original Message Follows----

Hello,

I've following (urgent) problem:

I have created an array, loaded with the values (put)(within a while-loop) 
and then accessed
the array with get (within a while-loop) for comparing the field description 
with a fixed
string (variable: 'Hugo').
Although I see the correct value of this array-field with DISPLAY, but  the 
IF-comparison
is not true.
What is the problem ?
In a next step, I delimited the description-field with   let ... = 
substr($bewdata_descr,1,4)
and compared with 'Hugo' , but I had again no success !!

Many thanks for your help !!!



  CREATE-ARRAY name=bewdata   size={max_entries_bewdata}
           field=description:char
           field=report-type:char
           field=excl-code:char
           field=firmnr:char
           field=pay-element:char:2
           field=element-code:char:3


      ....

       put $description $report_type $exclusion_code $firmnr $pay_element1 
$pay_element2
              $element_code1 $element_code2 $element_code3 into bewdata(#j)
              description report-type excl-code firmnr pay-element(0) 
pay-element(1)
              element-code(0) element-code(1) element-code(2)


   ....

  get $bewdata_descr $bewdata_report-type $bewdata_excl $bewdata_firmnr
           from bewdata(#i) description report-type excl-code firmnr

  if $bewdata_descr = 'Hugo'    !is always wrong


many thanks

     Annerose

Annerose Martin
Hewlett-Packard Boeblingen (Germany)
EMEA Payroll and Time Tracking IT Team

_________________________________________________________________
Limited-time offer: Fast, reliable MSN 9 Dial-up Internet access FREE for 2 
months! 
http://join.msn.com/?page=dept/dialup&pgmarket=en-us&ST=1/go/onm00200361ave/direct/01/


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

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