Page 1 of 1 1
Topic Options
#75160 - 2003-05-23 09:26 AM Adding values
attiahia Offline
Hey THIS is FUN

Registered: 2000-03-27
Posts: 268
Why I can not add $PFU values (cumulative) ?

$X=0
$AVRG=0
$Opn=Open(1,"D:\Task.txt",2)
DO
$Red=ReadLine(1)
$Red2 = LTRIM("$Red")
$B=INSTR($Red2, "PFU")
$PFU=Substr($Red2,$B,7)
? $PFU (first value for $PFU=90)
$AVRG=$AVRG + $PFU (now $AVRG should be 0 + 90= 90 but it still 0)
$X=$X+1
Until $X=5
$C=Close(1)

I tried the same thing with VAL but also did not work.
$AVRG=$AVRG + VAL(“$PFU”)

Please Help. Thank you.

Top
#75161 - 2003-05-23 09:29 AM Re: Adding values
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Try to convert as you substr()-ing it like

$pfu = val( substr($red2,$b,7) )
_________________________



Top
#75162 - 2003-05-23 09:37 AM Re: Adding values
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Are you sure that it is really only -90- and not maybe -90 - ???

Can be easily verified with :

"_" + $pfu + "_" ?
_________________________



Top
#75163 - 2003-05-23 09:55 AM Re: Adding values
attiahia Offline
Hey THIS is FUN

Registered: 2000-03-27
Posts: 268
I am confused because this was working fine with me long time ago, I do not know what happen? [Confused]
Following is example for the txt file I read from and for the output I got. [Frown]
Red2=Today=2003/05/22 Time=11:51:50 PFU=90
Today=2003/05/22
Time=11:51:50
_PFU=90_
AVRG=0

Red2=Today=2003/05/22 Time=11:52:02 PFU=140
Today=2003/05/22
Time=11:52:02
_PFU=140_
AVRG=0

Red2=Today=2003/05/22 Time=11:52:18 PFU=160
Today=2003/05/22
Time=11:52:18
_PFU=160_
AVRG=0

Note: I got 0 result for $pfu = val( substr($red2,$b,7) )
I am using Kix32 V 4.20.0.0
Thank you. [Embarrassed]

Top
#75164 - 2003-05-23 09:58 AM Re: Adding values
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
As said before ... it might happen that it IS a string unconvertable to integer as it might contain plain string characters in addition to the numbers that are obvious ...
_________________________



Top
#75165 - 2003-05-23 10:14 AM Re: Adding values
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Found it !

your $PFU variable should be (untested) :

PFU=90

using 4.20

So no wonder why val($PFU) returns 0 [Wink]

[ 23. May 2003, 10:15: Message edited by: Jochen ]
_________________________



Top
#75166 - 2003-05-23 10:19 AM Re: Adding values
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Without improving your code as is this should work :


$X=0
$AVRG=0
$Opn=Open(1,"D:\Task.txt",2)
DO
$Red=ReadLine(1)
$Red2 = LTRIM("$Red")
$B=INSTR($Red2, "PFU")
$PFU=val(Substr($Red2,$B+4,7))
? $PFU ;(first value for $PFU=90)
$AVRG=$AVRG + $PFU ;(now $AVRG should be 0 + 90= 90 but it still 0)
$X=$X+1
Until $X=5
$C=Close(1)


{oops}

[ 23. May 2003, 10:20: Message edited by: Jochen ]
_________________________



Top
#75167 - 2003-05-23 10:22 AM Re: Adding values
attiahia Offline
Hey THIS is FUN

Registered: 2000-03-27
Posts: 268
Give me some more time I think I will know the reason.
substr($red2,$b,7) include string + integer

Top
#75168 - 2003-05-23 10:27 AM Re: Adding values
attiahia Offline
Hey THIS is FUN

Registered: 2000-03-27
Posts: 268
I posted my reply before I see yours but I do not know how yours appear first? I think because you have stars while I do not. [Big Grin]
Thank you very much. [Wink]

Top
#75169 - 2003-05-23 10:44 AM Re: Adding values
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Nah .. the board had a slight Hickup (again)
_________________________



Top
#75170 - 2003-05-23 03:25 PM Re: Adding values
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
One more thing A.,

If you do control the way the file gets created think about an 16-bit INI format !
Much easier to control and way more reliable [Smile]
_________________________



Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.164 seconds in which 0.093 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org