String comparison instead of numeric
Posted: Wed Sep 03, 2008 2:48 pm
Hi,
I have a chunk of script which ckecks whether there are 4 GB available on target drive:
Set Variable TARGETDRIVE to $TARGETDIR$
Extract Parent Drive: TARGETDRIVE
Set Variable FREE_SPACE to 0
Get Free Space on $TARGETDRIVE$ into variable FREE_SPACE
if Variable FREE_SPACE not Greater Than 4000000000
MessageBox: $TITLE$ Setup Error, This installation requires at least 4 GB of available disk space in $TARGETDRIVE$. Please, free some disk space and run the installation again.$NEWLINE$$NEWLINE$Setup cannot continue.
Terminate Installation
end
The available free space is obtained ok, but when the comparison is performed, it is a STRING comparison and not a NUMERIC one, although both variables contain numbers (the help says in this case a numeric comparison is performed). So if the drive contains only 41 bytes free, the script passes the test because '41' is lexicographically after '4000000000'.
What to do?
I have a chunk of script which ckecks whether there are 4 GB available on target drive:
Set Variable TARGETDRIVE to $TARGETDIR$
Extract Parent Drive: TARGETDRIVE
Set Variable FREE_SPACE to 0
Get Free Space on $TARGETDRIVE$ into variable FREE_SPACE
if Variable FREE_SPACE not Greater Than 4000000000
MessageBox: $TITLE$ Setup Error, This installation requires at least 4 GB of available disk space in $TARGETDRIVE$. Please, free some disk space and run the installation again.$NEWLINE$$NEWLINE$Setup cannot continue.
Terminate Installation
end
The available free space is obtained ok, but when the comparison is performed, it is a STRING comparison and not a NUMERIC one, although both variables contain numbers (the help says in this case a numeric comparison is performed). So if the drive contains only 41 bytes free, the script passes the test because '41' is lexicographically after '4000000000'.
What to do?