Page 1 of 1 1
Topic Options
#78100 - 2001-07-10 05:15 PM Bug in calulations?
Anonymous
Unregistered


This strange thing keeps coming back:
Somewhere in the script I use counters like


$A=0
$A=$A+1 ;no problem "1"
$B=2
$B=$B+$A ; gives "21"

Sugestions please

Top
#78101 - 2001-07-10 05:20 PM Re: Bug in calulations?
Anonymous
Unregistered


I'm running KixTart 3.62 and your script worked fine for me. I got "3", not 21.
Top
#78102 - 2001-07-11 05:14 AM Re: Bug in calulations?
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
Either you are using a version of KiX prior to 3.62 or something else is wrong:

test.kix is

code:

$A=0
$A=$A+1
$B=2
$B=$B+$A
$B ?

I ran this command:
for %a in (k*.exe) do %a test.kix

so that your script would run on every version of KiX that I have...

The results

code:

C:\scripts>kix2kb1.exe test.kix
3

C:\scripts>kix2kb2.exe test.kix
3

C:\scripts>kix2kb2a.exe test.kix
3

C:\scripts>kix2kr40.exe test.kix
3

C:\scripts>kix2kr41.exe test.kix
3

C:\scripts>kix2kr42.exe test.kix
3

C:\scripts>kix2kr43.exe test.kix
3

C:\scripts>kix362.exe test.kix
3

C:\scripts>kix363.exe test.kix
3


as you can see, all versions reported 3.

Please post more code.

cj

Top
#78103 - 2001-07-11 11:31 AM Re: Bug in calulations?
Anonymous
Unregistered


Original code is to big to publish. The code here is just an example of what is used in the original. I just found out that somehwere in my code one of the variables was quoted like "$B". After removing the quotes and change the local code to
$C=$B and using $C for the quoted statement the the calculation went Ok. (Still strange..)

[ 11 July 2001: Message edited by: Loekw ]

Top
#78104 - 2001-07-11 11:43 AM Re: Bug in calulations?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
it's obvious that when you quoted "$b" it was translated to string.
but what is the thing about using $c. forgive for my not so fluent english, but did I understand right that you used $c in quotes?
_________________________
!

download KiXnet

Top
#78105 - 2001-07-11 09:12 PM Re: Bug in calulations?
Anonymous
Unregistered


I needed to display the $B value in a string. After I used $C=$B and then used the $C for the string funtion, all problems in the calculaton where gone.
Top
#78106 - 2001-07-12 02:34 AM Re: Bug in calulations?
cj Offline
MM club member
*****

Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
I consider the ""'s to be a semi-function because they will convert a numeric variable to a string.

ie

$a="$a" converts $a to a string.

$a=$a+10 will not add 10 to $a now, but will put "10" on the end of the string.

so if $a was 3, it becomes "3" and is now "310"

use VAL($a) to return to a number.

If you want to print $a IN a string you can:

"hello, $$a is now $a"

or

"hello, $$a is now " $a

Notice, there is no + anywhere there...


cj

Top
#78107 - 2001-07-12 09:28 AM Re: Bug in calulations?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
that's actually good to be noticed. I think it's mail-function... I mean... if i put
$a=4
$c=4
$ = "$a"
$z = $a + $c
$z will then output 44!!!
well it's undocumented function, and there could someone loose his hair... well not me but somebody...

[ 13 July 2001: Message edited by: Lonkero ]

_________________________
!

download KiXnet

Top
Page 1 of 1 1


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

Who's Online
0 registered and 1283 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

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