PDA

View Full Version : Conditional file run


RaptorX
09-03-2008, 08:28 AM
Hi guys.

Im having a little trouble creating a setup for personal use.

Basically what i will do is make an exe that contains the setups of the programs that i use the most, but giving me the option of selecting which setups to run.

looks simple but as i dont know much of lua scripting and the default options of the installer are not enough (even though they are perfectly helpful in more of my projects) I am having a little trouble here.

Example:

I have setup of adobe flash player which it doesnt matter which computer I am, I will needed it (and a bunch of other little setups).

I loaded the file in the project, in Before Installing I create a boxlist screen with a box labeled Adobe.

In the OnNext actions I put:

Adobe = DlgCheckBox.GetProperties(CTRL_CHECK_BOX_01);
Screen.Next();

so it checks the status of the box and saves it to Adobe.

Now here is the tricky part:

I want to check the status of CHECK_BOX_01 and IF checked then run the installer file... i tried with this:

In After Install>Preload tab I put this action:

if Adobe == tb.Checked then result = File.Run(SessionVar.Expand("%AppFolder%\\Adobe\\install_flash_player.exe"), "", "", SW_SHOWNORMAL, false);
end

If I try to put it in While Installing I have troubles cause it runs the setup over and over again while copying the files so that was the only way I came up with.

I tried tb.Checked, Checked... as you could imagine the adobe setup doesnt run. (which means that im close to my goal cause at least it makes the comparison) but still not enough.

Is there any other way that i can create a boxlist or a list of the programs in the setup that i can choose which ones to run or not... or it has to be manually done 1 by 1??

Thanks in advance and sorry for the long text but i wanted to be as descriptive as possible :D

RaptorX

Mark
09-03-2008, 11:38 AM
Hi RaptorX,

You are close to doing what you want however your script is slightly incorrect. What you should actually have is the following:


if (Adobe.Checked) then
result = File.Run(SessionVar.Expand("%AppFolder%\\Adobe\\in stall_flash_player.exe"), "", "", SW_SHOWNORMAL, false);
end


Since you are checking to see if the Adobe check box (which you stored the properties of in the Adobe table) has been checked.

This should work, but an easier way to do this is to use the the LUA Variable setting that each check box has. Take a look at the properties dialog of a check box and you will see what I mean. From the help file:


Store state in LUA variable:
The LUA variable that you want to store the state of the check box. If the check box is checked when leaving this screen, true will be stored. If the check box is unchecked, false is stored.


So what you could do for CTRL_CHECK_BOX_01 is set it's LUA variable setting to something like: install_adobe and then us the following code:


if (install_adobe) then
result = File.Run(SessionVar.Expand("%AppFolder%\\Adobe\\in stall_flash_player.exe"), "", "", SW_SHOWNORMAL, false);
end


Then you don't have to worry about getting the properties from the check box.

You should run your actions on the "On Post Install" event, or from a screen in the After Installing list.

You will have to do this for each additional install that you would like to run.

RaptorX
09-03-2008, 12:03 PM
Yep I was close...

When I read "tb.check" I thought it meant literally... shame on me.:rolleyes

Thanks for the explanation and the hints, cant be clearer than that.

I read the help file but I was little bit confused... it was actually easier than I thought.

I will give it a try tonight.

2 more questions if there is no problem:

1) can i run 2 or more files in the same IF statement?
ex. checking Adobe box would run Adobe Reader and Adobe flash player?

2) and what would be your suggestion for a checkbox that if checked set all the other boxes as marked so it would install all at once without checking each box (I have in mind the Dlgcheckbox.setProperties but Im also not sure on how to use it in this case.)

thanks in advance.

pww
09-03-2008, 03:59 PM
1) can i run 2 or more files in the same IF statement?

sure, as many as you need. You'd probably want to set WaitForReturn parameter to true so that installers run one after another - otherwise they'll be started all together and the script will immediately jump to the next command.

2) probably the simplest would be to set all per-installer lua variables to True if main checkbox is checked, sth like

if (install_all) then
install_adobe = true;
install_xxx = true;
-- ......
end

RaptorX
09-04-2008, 05:59 AM
thanks for all your help guys everytihng running smooth now. :D

Mark
09-04-2008, 09:05 AM
Hi RaptorX,

I'm glad that you have it all working.

If you do want a check box that will check all other check boxes you can use the MSGID_CLICKED notification message in combination with the DlgCheckBox.SetProperties() actions.

RaptorX
09-05-2008, 12:26 PM
Hi RaptorX,

I'm glad that you have it all working.

If you do want a check box that will check all other check boxes you can use the MSGID_CLICKED notification message in combination with the DlgCheckBox.SetProperties() actions.

Thanks but can you be little bit more specific cause as I mentioned before Im not good with the lua scripting, I tried something like this:

in the OnCtrl Message windows:

if (e_MsgID == CTRL_CHECK_BOX_01) then DlgCheckBox.SetProperties(CTRL_CHECK_BOX_02, Checked);
end

or

if (e_MsgID == CTRL_CHECK_BOX_01) then DlgCheckBox.SetProperties(CTRL_CHECK_BOX_02, {Checked = true});
end

and

if (e_CtrlID == CTRL_CHECK_BOX_01) then DlgCheckBox.SetProperties(CTRL_CHECK_BOX_02, Checked);
end

Also

if (MSGID_CLICKED == CTRL_CHECK_BOX_01) then DlgCheckBox.SetProperties(AFP.Checked);
end

and

if (MSGID_CLICKED == All) then DlgCheckBox.SetProperties(AFP.Checked);
end

By the way "All" is the lua variable assigned to the box that would select everything at once.

also tried


if (e_All_CLICKED) then DlgCheckBox.SetProperties(AFP.Checked);
end

and without the "e_" and so on and on....


all of them do nothing... Is the first time that i dont get from the help file... :D

It is very obscure for me and I dont understand why... I dont even understand the EXAMPLES.... Im getting old man... the age is getting me already... :lol

from the help file:

Notification Messages
A notification message is triggered whenever the user interacts with a control, or whenever user interaction affects a control in some way. Each notification message consists of a number that identifies the type of interaction that has occurred, and a table containing details specific to that type of interaction. These two values are passed to the screen's On Ctrl Message event as the event variables e_MsgID and e_Details.

Note: Notification messages are not triggered when actions interact with this control.

(number) e_MsgID
A numeric constant that represents the specific notification message that was fired by the screen control. See the e_MsgID column below for all possible message ids that can be fired by a check box control.

(table) e_Details
A table of additional details that may be passed by the control when certain notification messages are fired. See the e_Details column below for the kinds of details that are returned and the table indexes that you can use to access them. For example, you can access the item "Checked" from this table by using e_Details.Checked.

e_MsgID
e_Details
Description

MSGID_CLICKED
(boolean) Checked - Whether the check box is checked or not. The value true means it is checked and false means it is not.
Fired when the check box was clicked.



Related Actions
The following actions are available for interacting with a check box control:



DlgCheckBox.GetProperties

DlgCheckBox.SetProperties


and

Example 1
DlgCheckBox.SetProperties(CTRL_CHECK_BOX_02, tProperties);

Sets the properties for the '02' Check Box control to those contained in the table "tProperties".

Example 2
DlgCheckBox.SetProperties(CTRL_CHECK_BOX_03, {Visible = false, Enabled = false});

Disables and hides the '03' Check Box Control on the current screen.



But i dont know exactly what to substitute to create the correct formula, thats what i never get from the help file and seriously i dont know why i dont get it.

Well my setup is working fine I just want to have the select all button working. :)

thanks for all.

Mark
09-08-2008, 12:56 PM
Hi RaptorX,

Don't worry too much about it. Programming is an art form, and if you are just beginning you can't expect to "get it" all at once. Just keep working at it and once you "get it" it should stick.

From what you posted it looks like you need to pay closer attention to what the help file tells you the event variables are and how the Get and Set properties actions work.

Here is a short example of code that you can put on your "On Ctrl Message" event of a Check Box screen that will always update the "Checked" state of the second check box to be the same as the first check box.


-- Is this the clicked message sent from the right control?
if ((e_MsgID == MSGID_CLICKED) and (e_CtrlID == CTRL_CHECK_BOX_01)) then
-- Get the properties of the second check box
tbProps = DlgCheckBox.GetProperties(CTRL_CHECK_BOX_02)
-- Set the Checked property to be the same as Check 1
tbProps.Checked = e_Details.Checked
-- Update the second check boxes properties
DlgCheckBox.SetProperties(CTRL_CHECK_BOX_02, tbProps)
end


I hope this helps.

jcuster
09-08-2008, 01:47 PM
Hi RaptorX,

Don't worry too much about it. Programming is an art form, and if you are just beginning you can't expect to "get it" all at once. Just keep working at it and once you "get it" it should stick.

I hope this helps.

This is thread is really helping me out with the On Ctrl Message areas.

Thanks everyone.

RaptorX
09-09-2008, 01:44 PM
ok several things:

1) where should I report bugs?? I put the code and tried to preview it and it didnt do anything, I compiled the setup and tried again and then I could see the results, it seems to be that you cannot preview all the codes that you input.

2) it works perfectly, what i understand is that i was using HALF the code, MSGID just checked if it is clicked but it doesnt know WHO was clicked... thats where e_CtrlID comes in, I specify WHO is the one that has to be checked right?

then I get the properties of box 2 and save it into tbProps but, here is where im little bit confused when you set tbProps.Checked = e_Details.Checked because I dont see the condition when it is Unchecked... how does the computer recognize it?

Im sorry but I just want to be clear. As I said before everything is working fine. Thanks for all your help Mark and I will keep in mind about the help file.

:D