#169810 - 2006-10-24 06:06 AM
Problems with Commandline variables with large numbers
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4562
Loc: USA
|
When you supply a large number via a command line variable, the number is translated to something else. Even putting quotes around it, does not help. I'm not sure where the number starts, but its somewhere between 9 and 10 digits long. I've found that if I change the number to double (12345678901.0) it works fine, but it just seems odd to me that it would ignore the quotes and not treat it as a string. Can someone verify this.
test.kix Code:
break on
? $first ? $second ? $third ? $fourth
From commandline Code:
kix32 test.kix $first=1234567890 $second=12345678901 $third="1234567890" $fourth="12345678901"
Produces Code:
1234567890 -539222987 1234567890 -539222987
|
|
Top
|
|
|
|
#169811 - 2006-10-24 11:44 AM
Re: Problems with Commandline variables with large numbers
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
I've found that if I change the number to double (12345678901.0) it works fine
Actually, it doesn't. If you include a decimal character then the value is stored as a string, not a double.
On the plus side KiXtart handles intergers in scripts in exactly the same way, so at least it is consistant on that point!
Here is a more comprehensive test script showing the differences: Code:
Break ON $internal1=1 $internal2=1.2 $internal3=1234567890 $internal4=1234567890.1 $internal5=12345678901 $internal6=12345678901.1 $internal7=00001 $internal8='00001' If Not IsDeclared($external1) Run @SCRIPTEXE+' '+@SCRIPTDIR+'\'+@SCRIPTNAME +' $$external0' +' $$external1=1' +' $$external2=1.2' +' $$external3=1234567890' +' $$external4=1234567890.1' +' $$external5=12345678901' +' $$external6=12345678901.1' +' $$external7=00001' +' $$external8="00001"' Exit 0 EndIf 'KiXtart version: '+@KIX+@CRLF 'Internal (type) value : External (type) value'+@CRLF '0. ('+VarTypeName($internal0)+') '+$internal0+' : ('+VarTypeName($external0)+') '+$external0+@CRLF '1. ('+VarTypeName($internal1)+') '+$internal1+' : ('+VarTypeName($external1)+') '+$external1+@CRLF '2. ('+VarTypeName($internal2)+') '+$internal2+' : ('+VarTypeName($external2)+') '+$external2+@CRLF '3. ('+VarTypeName($internal3)+') '+$internal3+' : ('+VarTypeName($external3)+') '+$external3+@CRLF '4. ('+VarTypeName($internal4)+') '+$internal4+' : ('+VarTypeName($external4)+') '+$external4+@CRLF '5. ('+VarTypeName($internal5)+') '+$internal5+' : ('+VarTypeName($external5)+') '+$external5+@CRLF '6. ('+VarTypeName($internal6)+') '+$internal6+' : ('+VarTypeName($external6)+') '+$external6+@CRLF '7. ('+VarTypeName($internal7)+') '+$internal7+' : ('+VarTypeName($external7)+') '+$external7+@CRLF '8. ('+VarTypeName($internal8)+') '+$internal8+' : ('+VarTypeName($external8)+') '+$external8+@CRLF
Output is: Code:
Internal (type) value : External (type) value 0. (Empty) : (Empty) 1. (Long) 1 : (Long) 1 2. (Double) 1.2 : (String) 1.2 3. (Long) 1234567890 : (Long) 1234567890 4. (Double) 1234567890.1 : (String) 1234567890.1 5. (Long) -539222987 : (Long) -539222987 6. (Double) 12345678901.1 : (String) 12345678901.1 7. (Long) 1 : (Long) 1 8. (String) 00001 : (Long) 1
As you can see, there are two major differences.
- Any number with a decimal character is treated as a string instead of a double when supplied as a command line parameter.
- Any string which comprises numeric characters (0-9) gets converted to a long even if it is surrounded by quotes. In the case of test 8 this drops leading zeroes from the string, which loses significant information.
I agree that if you surround a command line parameter with quotes, then you should reasonably expect it to be treated as a string rather than a number.
|
|
Top
|
|
|
|
#180025 - 2007-08-31 01:30 PM
Re: Problems with Commandline variables with large numbers
[Re: Ruud van Velsen]
|
Ruud van Velsen
Developer
   
Registered: 1999-05-06
Posts: 391
Loc: Amsterdam, The Netherlands
|
Basically, what you are running into is the maximum number KiXtart can store in its 32-bit variables (from the manual: "Integer variables can contain any value between 2,147,483,648 and 2,147,483,647").
The number you are trying to store is 12,345,678,901. This overflows the 32-bit integers and produces unexpected numbers.
As for ignoring quotes on the commandline: this is due to the fact that the generic application startup code drops the quotes before presenting the commandline to the application (== KiXtart). So KiXtart doesn't even get a chance to ignore them... I could change KiXtart to handle the "raw" commandline (which is what you see when you call GetCommandLine()), but this involves dealing with all sorts of other exceptions as well. I'll put this on the research-list to see if this is doable for a future update.
Kind regards,
Ruud
|
|
Top
|
|
|
|
Moderator: ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|