PDA

View Full Version : Error 9 - "Cannot find variable" which exists



flashpot
06-11-2008, 10:36 AM
I receive a frequent compiler error (it does not happen all the time, but enough that I cannot deploy the software) indicating [9] cannot find variable %JAVAINSTALLED% A screen clip of the error is attached.

In my script, I have the following code:

Set Variable %JAVAREGISTERED% to FUNCTION:Get INI Value("JavaInstalled") from "%_SB_INSTALLDIR%\CountOps.Ini"
If %PROGRAMFILESDIR%\JAVA\J2RE1.4.2_17 File or Folder exists Then
Set Variable %JAVAINSTALLED% to "1"
Else
Set Variable %JAVAINSTALLED% to "0"
End
If %JAVAINSTALLED% Not Equals "0" Then
Set Variable %INSTALLSHORTCUTS% to "0" [Append Value]
If %JAVAREGISTERED% Equals "0" Then
Set Variable %INSTALLSHORTCUTS% to "1" [Append Value]
Else
Set Variable %INSTALLSHORTCUTS% to "0" [Append Value]
End
Else
Set Variable %INSTALLSHORTCUTS% to "11" [Append Value]
End
Define Wizard Dialog "PROGRAMOPTIONS" (Check Boxes) (%INSTALLSHORTCUTS%) -- Program Shortcuts

Any ideas why the variable is not being set? Is it a reserved word? I have retyped the variable a number of times (with and without the bracketing "%s") to no avail.

I guess the next logical thing to do would be to change the variable to something else...

Thanks!

Rob

linder
06-11-2008, 10:40 AM
Rob,

"Initialize" the %JAVAINSTALLED% variable at the beginning of your script and recompile your project. This should do it.

Does this help?

Friedrich

flashpot
06-11-2008, 11:27 AM
Friedrich,

It is even simpler than that. I had built the program using Arnor's Build Automator but neglected to initialize the variable on the other branch of an if/then statement.

In my haste, I recompiled from SetupBuilder and uploaded the file, but named the .exe extension lowercase instead of title case. The Apache server where I uploaded the file treated the newly-uploaded file as a different file and did not overwrite the other one. Every install that failed was with the first version that existed before I found the problem and recompiled.

I just deleted both versions, will rebuild and upload and give it another try.

I KNEW it had to be something I was doing wrong, but I now understand that it is best to initialize EVERYTHING used and not count on initializing the variables in the script when there is a possibility of a branch around it.

Thanks!

Rob

linder
06-11-2008, 12:39 PM
Thanks for the update, Rob!

Friedrich