PDA

View Full Version : CheckBox Question



Sanchivan
04-06-2006, 02:31 PM
Hi,

I have three checkboxes(Trace Enabled, LogFile, LogEvent) in one of my dialog. The property names for these CheckBoxes are:
1. Trace enabled -> TRACEENABLED
2. LogFile -> LOGFILE
3. LogEvent -> LOGEVENT

Also, I have a Custom Action called SharedSettings and the vb script within this Custom Action is:

IF Session.Property("TRACEENABLED") = 1 THEN
Session.Property("BOOLTRACEENABLED") = "True"
ELSEIF Session.Property("TRACEENABLED") <> 1 THEN
Session.Property("BOOLTRACEENABLED") = "False"
END IF

IF Session.Property("LOGFILE") = 1 THEN
Session.Property("BOOLLOGFILE") = "True"
ELSEIF Session.Property("LOGFILE") <> 1 THEN
Session.Property("BOOLLOGFILE") = "False"
END IF

IF Session.Property("LOGEVENT") = 1 THEN
Session.Property("BOOLLOGEVENT") = "True"
ELSEIF Session.Property("LOGEVENT") <> 1 THEN
Session.Property("BOOLLOGEVENT") = "False"
END IF

I have defined the Properties(BOOLTRACEENABLED, BOOLLOGFILE, BOOLLOGEVENT) in the Property Manager with value "0".

In the XML File Changes View I am writing these three properties into an xml. so if a user selects any of the check box then a value of "True" is written to the xml and if a user unchecks the check box then a value of "False" is written into the xml. Well, that is what I want to archieve.

Also, I have deleted the property LOGEVENT from the Property Manager because I want that check box to be unchecked as default and the other two to be checked.

The result that I have right now is when I actually have all three check box checked,then it installs fine and writes a Value of "True" into the xml. But if I uncheck any of the checkbox, and click Next it just goes straight to the Finish page without installing the package. I noticed the value of the Properties of the checkboxes are null("") when a it is unchecked and it's 1 when it is checked. The script should be able to handle this because I check if the property <> 1. So I don't know what I am wrong. Could someone please help me please. Thanks.

Sanchivan
04-07-2006, 08:49 AM
Hi,

I was trying to see why it skips the installation by running through the MSI Debugger. When I do that, it actually installs, but it puts the value "0" instead of "False", but if I have something checked then it puts the value "True". That is kind of strange, then I actually rant he package again, but then again it skips. The MSI Debugger code that I have is kind of messed up I think. It doesn't really look like what I have in the sequence view. You could notice this in the attachment that I have PatchWelcome twice, and InstallWelcome Twice, so I don't know. Well, I think this happens each time you delete fromt he sequence and add it again. Well, I am not sure. Please help me. Thanks.

Sanchivan S.

Aflaat
04-07-2006, 10:26 AM
It might be crapping out in your VB code. Note that when you uncheck a check box the property is null. So you have a value of 1 or NULL, not 1 or not 1.

RobertDickau
04-07-2006, 10:34 AM
You might also want to try string comparisons in your VBScript code:

If Property("TEST")="1" Then ' etc.

Sanchivan
04-07-2006, 03:27 PM
Hi Robert,

I tried what you told me, but it doesn't work. when I run the package, it just skips to the finished page. And when I run it on debugger mode, it installs it but puts a value of 0. I tried checking if the property is equal to NULL and also "0". Neither of them worked for me. Can you please help me. thanks.

Sanchivan S.

Sanchivan
04-07-2006, 03:36 PM
Could someone teach me how to check if a particular custom action is called through debugger?

RobertDickau
04-07-2006, 04:01 PM
Can you put a breakpoint there? You'll probably want to enable the MSI Debugger toolbar with Tools > Customize.

At the beginning of the thread you mentioned giving your check box properties the value "0", but apparently you're checking for value "1". Does changing the initial Property table value to "1" make any difference? Does a call to MsgBox in your action do anything?

Sanchivan
04-10-2006, 10:10 AM
Hi Robert,

I have the values for the properties as "1" that did not work. Here is what I have with the messagebox when the TRACEENABED checkbox is unchecked.
It throws like empty string or something into the MsgBox. I tried to check the empty string, that doesn't work either. So I really don't know what I should be checking here. So far I have checked for the following values when a property of a checkbox is unchecked. They are "0", NULL, "". Could you please help me please. Thanks.

Sanchivan S.

RobertDickau
04-10-2006, 11:06 AM
In VBScript, it seems testing an empty property value against "" works.

And in the If statements, I would put quotes around the value 1, as in:

If Property("TEST")="1" Then ' etc.

Sanchivan
04-10-2006, 11:08 AM
Hi,

I read in the following Q103219 (http://support.installshield.com/kb/view.asp?articleid=Q103219) article, and it says that when the checkbox is unchecked, the PROPERTY is actually deleted from the Property Manager and when it is checked, it is created again. So if the property doesn't even exist, how am I supposed to check for it?

Sanchivan

RobertDickau
04-10-2006, 11:17 AM
A quick test seems to suggest that comparing against the null string "" works.

Sanchivan
04-10-2006, 02:00 PM
It doesn't work for me.
This is what I have:

IF Session.Property("TRACEENABLED") = 1 THEN
Session.Property("BOOLTRACEENABLED") = "True"
ELSEIF Session.Property("TRACEENABLED") = "" THEN
Session.Property("BOOLTRACEENABLED") = "False"
END IF

IF Session.Property("LOGFILE") = 1 THEN
Session.Property("BOOLLOGFILE") = "True"
ELSEIF Session.Property("LOGFILE") = "" THEN
Session.Property("BOOLLOGFILE") = "False"
END IF

IF Session.Property("LOGEVENT") = 1 THEN
Session.Property("BOOLLOGEVENT") = "True"
ELSEIF Session.Property("LOGEVENT") = "" THEN
Session.Property("BOOLLOGEVENT") = "False"
END IF

I think I can do this by settling the BOOLTRACEENABLED, BOOLLOG and BOOLLOGEVENT to "False" and if I am able to check if the Property actually is active or exists,t hen I could check if it's 1 and if it is set it to "True". But I don't know how to check if a Property exists, can you tell me how to check thanks.

RobertDickau
04-10-2006, 06:02 PM
If you create an MSI log file, are the property values correct?

If so, as I suggested earlier you might try quoting the property values in your test:

If Property("TEST")="1" Then ' etc.

instead of:

If Property("TEST") = 1 Then ' ...

Sanchivan
04-11-2006, 02:19 PM
How do you create the MSI Log File?

RobertDickau
04-11-2006, 03:02 PM
You can use the /L switch to msiexec:

msiexec /i product.msi /Lp properties.log

Sanchivan
04-11-2006, 03:37 PM
It writes the the Properties of the checkboxes that are checked. but if a checkbox is unchecked, it doesn't write anything into the log file. so I dont' know what to do.

Sanchivan
04-11-2006, 03:42 PM
How Can I check if a certain Property Exists? That is what I need. Because the log fine is saying that It is failing on the Custom Action, and I do expect it to fail because when the user unchecks the checkbox, that property doesn't even exist, but in the custom action, I am checking for that property so it will fail. Can you tell me how can I check if a certain property exists or not? Thanks.

Sanchivan S.

RobertDickau
04-11-2006, 03:43 PM
Right, if it's unchecked you might try testing if the (nonexistent) value is equal to the null string ""...

Sanchivan
04-11-2006, 04:20 PM
I am not sure what you mean

RobertDickau
04-12-2006, 08:53 AM
I imagine:

If (Property("SOMETHING")="") Then ' etc.

Sanchivan
04-12-2006, 09:15 AM
Thank you so much Robert. I really appreciate it. It worked. :) Just in case if somebody else is going through the same problem as I am, here is how the script looks. Thanks again robert. you are the best. :)

IF (Session.Property("TRACEENABLED") = "") THEN
Session.Property("BOOLTRACEENABLED") = "False"
ELSEIF (Session.Property("TRACEENABLED") = 1) THEN
Session.Property("BOOLTRACEENABLED") = "True"
END IF

IF (Session.Property("LOGFILE") = "") THEN
Session.Property("BOOLLOGFILE") = "False"
ELSEIF (Session.Property("LOGFILE") = 1) THEN
Session.Property("BOOLLOGFILE") = "True"
END IF

IF (Session.Property("LOGEVENT") = "") THEN
Session.Property("BOOLLOGEVENT") = "False"
ELSEIF (Session.Property("LOGEVENT") = 1) THEN
Session.Property("BOOLLOGEVENT") = "True"
END IF