[compiler if Variable ...] always runs regardless of value

Got a problem you cannot solve? Try here.
erich.einfalt
Posts: 32
Joined: Mon Oct 29, 2012 2:27 pm

[compiler if Variable ...] always runs regardless of value

Postby erich.einfalt » Tue Feb 09, 2016 9:17 pm

Installware X3, Win8.1

The attached screen capture shows that DEBUG_TEST is getting set to the value within the [compiler if Variable VDI not Equals TRUE] even when the compiler variable VDI is defined (in Project Options->Compiler Variables) as TRUE. DEBUG_TEST (at the breakpoint behind the Watches window) should show either empty (or maybe "variable not defined"). All the other [compiler if Variable VDI not Equals TRUE] blocks in this script (the main script) also incorrectly execute the code within the compiler if Variable... block.

What am I missing?
Attachments
IfCompilerVariableFailureCapture.PNG
IfCompilerVariableFailureCapture.PNG (37.43 KiB) Viewed 6437 times

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

Re: [compiler if Variable ...] always runs regardless of val

Postby bokkie » Wed Feb 10, 2016 4:04 am

Good morning, Erich.

I took a look at this and I've attached a minimal project. I tried setting a compiler variable, VDI, to both TRUE and FALSE and things seem to work okay for me. I tried to replicate similar code as you provided. Could you try running my project and see if mine works differently to yours?

The only thing that puzzled me is why you set the DEBUG_TEST variable's value to the literal string "not Equals TRUE". For sure I used the same value in an "if" statement but if I wanted to use it elsewhere I could see myself possibly checking for "Not Equal TRUE" which isn't the same as "Not Equals True". Is that what you had in mind? I ask because I would normally use values 0 or 1 in my "if" statements but that's just my preference.

I mention this in case you might be tired and overlooked a syntax problem. :D

I also admit that I might be tired and overlooked a syntax problem as well. :D
Attachments
TestCompilerVariable.7z
(1.07 KiB) Downloaded 315 times
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP

erich.einfalt
Posts: 32
Joined: Mon Oct 29, 2012 2:27 pm

Re: [compiler if Variable ...] always runs regardless of val

Postby erich.einfalt » Wed Feb 10, 2016 12:54 pm

Thanks for the quick reply.

Yes, your minimal test project worked as expected. So I reloaded the project exhibiting the reported behavior and upon recompiling it, I am now getting "Insuffient COMPILER VARIABLE END statements" error.

I loaded the main project script's .txt file into NotePad++ and performed searches for "[compiler if Variable" and "[compiler end" and found the counts for both searches match. I manually re-examined the main project script along with all the smaller scripts in the InstallAware IDE and found no [compiler if Variable ...] statements that lacked a corresponding [compiler end] statement.

My question now is: Can [compiler if Variable...]/[compiler end] statement pairs be nested if target compiler variable of the inner [compiler if Variable...]/[compiler end] pair is different than target compiler variable of the outer [compiler if Variable...]/[compiler end] pair?

i.e --
[compiler if Variable MY_COMPILER_VAR1]
...
[compiler if Variable MY_COMPILER_VAR2]
...
[compiler end] >>>>>>>>>>>>>>>> It is assumed that this compiler end refers to MY_COMILER_VAR2 because there is no indication in the [compiler end] statement regarding which compiler variable this inner [compiler end] refers to.
...
{compiler end] >>>>>>>>>>>>>>>> It is assumed that this compiler end refers to MY_COMILER_VAR1 because there is no indication in the [compiler end] statement regarding which compiler variable this inner [compiler end] refers to.

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

Re: [compiler if Variable ...] always runs regardless of val

Postby bokkie » Wed Feb 10, 2016 2:17 pm

Good question. I don't know for sure but something in my mind tells me that you can't nest them as I recall something like that being asked a long time ago. I will have a look later on and will let you know if I find anything to confirm it one way or the other.

I suspect we might need Francesco to answer that for us.
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: [compiler if Variable ...] always runs regardless of val

Postby FrancescoT » Wed Feb 10, 2016 2:20 pm

Dear Erich,

if you mean;

Code: Select all

[compiler if Variable MY_COMP_VAR_ONE Equals A]
MessageBox: , MY_COMP_VAR_ONE = A
[compiler if Variable MY_COMP_VAR_TWO Equals B]
MessageBox: , MY_COMP_VAR_TWO = B
[compiler end]
[compiler end]

Yes, it can be used ...of course, the nested "Compiler IF" will be detected by the compiler only when the first compler directive will be true.

However, I don't like so much such approach.

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: [compiler if Variable ...] always runs regardless of val

Postby bokkie » Wed Feb 10, 2016 3:11 pm

Erich,

I can also confirm what Francesco has written. I've attached another minmal project that shows compiler variable nesting. It works okay.
Attachments
TestCompilerVariable.7z
(1.29 KiB) Downloaded 319 times
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP

erich.einfalt
Posts: 32
Joined: Mon Oct 29, 2012 2:27 pm

Re: [compiler if Variable ...] always runs regardless of val

Postby erich.einfalt » Thu Feb 11, 2016 10:57 am

UPDATE: I, too, have confirmed that while, technically possible, nested compiler if variable/compiler end pairs, depending upon the work being done within the nested blocks, can result in undesired and unexpected results.

In my situation, these undesired effects resulted in corruption to various portions of the entire project and these said corruptions were detected in the behavior originally reported in this forum thread, namely that the evaluation of the compiler if Variable always seemed to proceed as though it always evaluated as true. The remedy was to discard all the changes since this project's last successful code repository check-in and rethink my approach, namely, create a script variable early in the main script that takes the value of the compiler variable and then perform all code branching based on if Variable-else-end statements on that script variable. Final result, this project is back on track and new features are functioning as specified.

Thanks for the responses.

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

Re: [compiler if Variable ...] always runs regardless of val

Postby FrancescoT » Thu Feb 11, 2016 1:32 pm

:D
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 119 guests