PDA

View Full Version : StrToNum is broken?



Rincewind
10-05-2011, 06:39 PM
I have some code to check the sub-version number of the installed Java by stipping the number from the end of the install path (retrieved from the registry). However, the StrToNum function is returning zero. Here is the code:


STRING szJavaHome, szJavaDir, szJavaVer;
NUMBER nJavaVer;
BOOL bGoodJava;
if (StrLength(szJavaHome) > 1) then
if (ParsePath(szJavaDir,szJavaHome,FILENAME) = 0) then
if (StrSub(szJavaVer,szJavaDir,StrFind(szJavaDir,'_')+1,2) = 0) then
if (StrToNum(nJavaVer,szJavaVer) = 0) then
if (nJavaVer >= 26) then
bGoodJava = TRUE;
endif;
endif;
endif;
endif;
SprintfBox(INFORMATION,"","%s\n%s\n%s\n%ld",szJavaHome,szJavaDir,szJavaVer,nJavaVer);


The result is:
C:\Program Files (x86)\Java\jdk1.6.0_26
jdk1.6.0_26
26
0

Obviously, the StrToNum function is failing, but I can't tell why.

RobertDickau
10-05-2011, 08:02 PM
StrSub doesn't return 0 for success, so maybe the inner StrToNum just isn't being called?

Rincewind
10-06-2011, 08:09 AM
Oops, teach me to read the documentation.
Guess that should be >0.
Thanks Robert.