Page 1 of 1 1
Topic Options
#36102 - 2003-02-06 11:41 AM Problem with Val
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
#36103 - 2003-02-07 12:23 AM Re: Problem with Val
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
is this the whole script?
it looks ok so I must wonder do you have missing quote or bracket before this line.
_________________________
!

download KiXnet

Top
#36104 - 2003-02-06 01:34 PM Re: Problem with Val
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
#36105 - 2003-02-06 03:00 PM Re: Problem with Val
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
couldn't find any syntastical error even though scanned for long time...
try changing this line though:
$size_part=substr($linein,1,instr($linein," "))

to this:
$size_part=""+substr($linein,1,instr($linein," "))

and tell did it change anything.
_________________________
!

download KiXnet

Top
#36106 - 2003-02-06 03:06 PM Re: Problem with Val
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
#36107 - 2003-02-06 03:08 PM Re: Problem with Val
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
What happens if you hand bomb something like this.
code:
break on 

$Size="123"
$Size_part="123"
$size=val($size)+val($size_part)
$size
get $_

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#36108 - 2003-02-06 03:29 PM Re: Problem with Val
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
quote:
value contains 2.66
What Kix version?

Didn't older versions only support INTs?

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#36109 - 2003-02-06 03:34 PM Re: Problem with Val
Anonymous
Unregistered


Glenn

Thats sorted it, I was using an older version. upgraded to 4.12 and its now working. Thanks everyone!

Top
#36110 - 2003-02-06 04:13 PM Re: Problem with Val
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You should also read up on the difference between VAL(), CDBL(), CINT() in case you deal with large numbers.

[ 06. February 2003, 16:14: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


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

Who's Online
1 registered (Allen) and 4358 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.547 seconds in which 0.51 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