(Pre-) Definition of Variables

Got a problem you cannot solve? Try here.
InstallAware@Jelich.info
Posts: 41
Joined: Mon Apr 13, 2009 8:58 am

(Pre-) Definition of Variables

Postby InstallAware@Jelich.info » Fri Nov 06, 2015 2:18 pm

Hi Support Team,

Am I right in my assumption that
- any action providing a combo box for the variable (e.g. Check For Process) does not require the variable to be defined in advance (Set Variable)
- any action with only an edit field for the variable (e.g. Call DLL Function) requires the variable to be defined earlier in the script?

Or is the key difference Build-In Command vs. Plug-In Command?

Best regards
Michael

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: (Pre-) Definition of Variables

Postby FrancescoT » Mon Nov 09, 2015 7:56 am

Dear Michael,

it's Always required to declare "CUSTOM" variables before to use them.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

InstallAware@Jelich.info
Posts: 41
Joined: Mon Apr 13, 2009 8:58 am

Re: (Pre-) Definition of Variables

Postby InstallAware@Jelich.info » Tue Nov 10, 2015 1:35 pm

Dear Francesco,

I do not agree with you. Please try the following:

Read Registry Key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\CommonFilesDir into GUCKSTDU
MessageBox: Huhu, $GUCKSTDU$


{MSI Script:
~InstallAware Clipboard Data~
~MessageBox~
~{4EDD1630-D9DB-41E9-A0AC-0BFE26F00C7D}~
~Huhu~
~$GUCKSTDU$~
~0~
~1~
~~
~Read Registry~
~{2922F9C7-CDD5-4F33-9410-58D70A5F9B26}~
~GUCKSTDU~
~2~
~SOFTWARE\Microsoft\Windows\CurrentVersion~
~CommonFilesDir~
}

This works fine without any error. I'm pretty sure that GUCKSTDU is not a predefined variable and thus considered a custom variable. It is NOT declared in the Compiler Variables section or anywhere else before use.

I also discovered during PlugIn development that I can add variables to the 'Variables' argument of function 'RunTimeExecute' without any error - the added variable and its value is accessible (and correct) in my Native Setup MSI Script. Therefore using undeclared variables is also successful using my PlugIn's.

I have not very often an error message claiming the usage of undefined variables (but I remember that I've had some... - but I cannot remember the commands/actions raising the error).

Does the script above raise an error in your IA IDE?

Best regards
Michael

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: (Pre-) Definition of Variables

Postby FrancescoT » Tue Nov 10, 2015 1:58 pm

Dear Michael,

it Always a good and recommended practice to DECLARE CUSTOM VARIABLES before to use them ... you may have un-expected results and especially when passing values to a plugin.

I full understand what you are trying to prove and under some circumstances it may work ... but believe me, I highly recommend you to declare them.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

bokkie
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Re: (Pre-) Definition of Variables

Postby bokkie » Tue Nov 10, 2015 2:29 pm

InstallAware@Jelich.info wrote:Dear Francesco,

I do not agree with you. Please try the following:

Read Registry Key HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\CommonFilesDir into GUCKSTDU
MessageBox: Huhu, $GUCKSTDU$



Michael,

Don't ignore Francesco's advice about declaring your variables before you use them. I would say 99.9% of the time you will get away with it if you don't declare them. Most statements and plugins will be kind to you. Don't push your luck because one day an undeclared variable just might turn around and bite you. I've never had a problem with my own plugins but I always make sure I declare my variables at the top of the script and give them default values where possible.
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP

InstallAware@Jelich.info
Posts: 41
Joined: Mon Apr 13, 2009 8:58 am

Re: (Pre-) Definition of Variables

Postby InstallAware@Jelich.info » Tue Nov 10, 2015 3:23 pm

Peter and Francesco,

I assumed that pre-definition was a 'relict' from earlier versions because I very often see undeclared variables used (e.g. SELECTED, SUCCESS,...)

Thank you for your advice. I'll consider your recommendation. Should not be difficult ;-)

But if it is of that importance, what do you think about a check during compile? (like 'OPTION EXPLICIT' in other 'languages'?) In case undeclared variables are used compile should fail or at least generate a warning...

Best regards
Michael

bokkie
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Re: (Pre-) Definition of Variables

Postby bokkie » Wed Nov 11, 2015 9:47 am

I like that idea of an OPTION EXPLICIT concept. It would certainly be useful. I'd envisage it being implemented as an IDE setting. I will ask someone who knows someone at InstallAware who might be able to punt it for consideration.

Francesco? Are you there? :D
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: (Pre-) Definition of Variables

Postby FrancescoT » Wed Nov 11, 2015 12:53 pm

I am having a beer on a lost beach of a unreachable country ...bip ...bip... can you hear me? 8)

Let me check your request!

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE

FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: (Pre-) Definition of Variables

Postby FrancescoT » Thu Nov 19, 2015 12:04 pm

Dear Michael and Peter,

I am sorry ... but I believe it'll be very very difficult to implement a sort of OPTION EXPLICIT.

In reality the compiler already checks variables declaration, but this is limited to those used with internal IA commands or statements.
Unfortunately this is not possible when a script entry refers to a plugin statement or similar.
In this circumstances the compiler cannot verify if a variable has been used with a specific "script line". This due the fact that the compiler ignores the logic that stays behind a plugin entry ... and this cannot be different ... unless the plugin doesn't implement a specific "build time method" at such purpose ... but this becomes to be a complicated thing.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 182 guests