#36102 - 2003-02-06 11:41 AM
Problem with Val
|
Anonymous
Anonymous
Unregistered
|
I am trying to add a couple of values to get a total from different entries in files. I am reading the value in correctly and placing it into the $size_part variant, then trying to sum it up with code:
$size=val($size)+val($size_part)
however this is returning an error in parameters error. I have initialised $size with 0 but still cannot get this to work. Please help! [ 06. February 2003, 13:31: Message edited by: chris_bol ]
|
|
Top
|
|
|
|
#36104 - 2003-02-06 01:34 PM
Re: Problem with Val
|
Anonymous
Anonymous
Unregistered
|
Lonkero, thats what I thought, but the executable obviously has other ideas! here is the full script if this may help. FYI the file it is reading from is in the format
code:
Size (mb) Files Directory 6.26 19 F: 3.51 13 F:Data 157.05 183 F:Epos 10.19 226 F:Frames 52.33 45 F:Help 0.17 13 F:Lenstech 0.00 1 F:Mail_In
code:
break on cls
$filepath="\\bolalbdatasrv01\hodata\cp\" $list_file="c:\temp\files.lst" $results="c:\results.csv" $cr=chr(13)+chr(10)
shell '%comspec% /c dir /b '+$filepath+'*.txt > '+$list_file
$null=open(1,$list_file) $null=open(10,$results,5)
$filein=readline(1)
while @error=0
$store_number=substr($filein,instr($filein,"ALB")+3,4)
?"Store Number= "$store_number
$null=open(2,$filepath+$filein)
$size=0 $linein=readline(2)
while @error=0 if instr($linein,"copy")<>0 gosub process_line endif
$linein=readline(2) loop $null=close(2)
$null=writeline(10,$store_number+","+$size+$cr)
$filein=readline(1)
loop
$null=close(10)
exit
:process_line
$char_in=substr($linein,1,1)
while $char_in=" "
$linein=substr($linein,2,len($linein))
$char_in=substr($linein,1,1)
loop
$size_part=substr($linein,1,instr($linein," "))
$size=val($size)+val($size_part)
return
|
|
Top
|
|
|
|
#36106 - 2003-02-06 03:06 PM
Re: Problem with Val
|
Anonymous
Anonymous
Unregistered
|
Tried that Lonkero, but it is still not working. I've added a line to print the result of $size_part, and it falls over when this value contains 2.66. Could it be the floating value that is causing the problem do you think?
|
|
Top
|
|
|
|
#36109 - 2003-02-06 03:34 PM
Re: Problem with Val
|
Anonymous
Anonymous
Unregistered
|
Glenn
Thats sorted it, I was using an older version. upgraded to 4.12 and its now working. Thanks everyone!
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1047 anonymous users online.
|
|
|