Page 1 of 1 1
Topic Options
#169810 - 2006-10-24 06:06 AM Problems with Commandline variables with large numbers
Allen Administrator Offline
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 Offline
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
#169812 - 2006-11-21 03:50 AM Re: Problems with Commandline variables with large numbers
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
I didn't get to deep into testing it, but the getcommandline() function appears to leave the large numbers alone... so at least there is one way to get those numbers into the script properly.
Top
#179982 - 2007-08-30 02:17 PM Re: Problems with Commandline variables with large numbers [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Ruud... any comments on this thread?
Top
#180022 - 2007-08-31 12:00 PM Re: Problems with Commandline variables with large numbers [Re: Allen]
Ruud van Velsen Moderator Offline
Developer
*****

Registered: 1999-05-06
Posts: 391
Loc: Amsterdam, The Netherlands
Thanks for the report, I will investigate...

Ruud

Top
#180025 - 2007-08-31 01:30 PM Re: Problems with Commandline variables with large numbers [Re: Ruud van Velsen]
Ruud van Velsen Moderator Offline
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
#180031 - 2007-08-31 03:18 PM Re: Problems with Commandline variables with large numbers [Re: Ruud van Velsen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
Thanks for looking at it.
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
1 registered (Allen) and 1198 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.065 seconds in which 0.035 seconds were spent on a total of 13 queries. Zlib compression enabled.