ipollock
Posts: 137
Joined: Wed Aug 31, 2016 10:46 am

Incrementing Value2 from Value1

Tue Oct 02, 2018 5:28 pm

I have an installer with two values.

When value1 is entered via a dialogue during install, i want value2 to have same value but incremented by 1.
For example: Please enter value1: 10 - value 2 then becomes 11.

These two values will then go on to update two values in XML (i know this bit) :)

Any help greatly appreciated.

Catalin
Posts: 6543
Joined: Wed Jun 13, 2018 7:49 am

Re: Incrementing Value2 from Value1

Wed Oct 03, 2018 10:56 am

Hello,

In order to achieve what you want, we can use a "PowerShellInline" custom action without sequence. We use it without sequence, so we can trigger it from a dialog control. In order to add a custom action without sequence, simply press the "Add custom action without sequence" button which is located to the right side of the custom action name. Since the values that are entered are saved as strings, the powershell script needs to take that string value, convert it to an integer and then increment it by 1.

To do this, please proceed as it follows:

Before we begin, a quick note: Since I do not have any further information about your scenario (e.g what dialog you have the control on, etc.) I will further proceed using my example. Just modify it for your needs.

- The first step I took was to add on the "FolderDlg" an edit box where I will introduce the value that I want incremented. The property that stores the value we introduce at the install time is called, in my case, EDIT_1_PROP.

- Now, please go to "Custom actions" page and add a "PowerShellScriptInline" custom action without sequence. After doing so, under the "Your code goes here." comment, please add the following code:

Code: Select all

$string = AI_GetMsiProperty EDIT_1_PROP
$integer = [int]$string+1
AI_SetMsiProperty MY_PROP "$integer"
In the code above, the second property is the one that is obtained by incrementing the value of the first one by 1 and I named it "MY_PROP". You can name it however you want.

- After doing so, please go back to "Dialogs" page, click on "FolderDlg" --> click on the "Next" button --> under "Published Events" tab click on the "New..." button:

-Event: Execute Custom Action
-Argument: PowerShellScriptInline
-Condition: leave unchanged. The default condition is "1" (or "AI_INSTALL")

Please let me know if this helps!

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

ipollock
Posts: 137
Joined: Wed Aug 31, 2016 10:46 am

Re: Incrementing Value2 from Value1

Wed Oct 03, 2018 1:54 pm

Thanks, i will give that a go and get back to you.

Best regards,

Catalin
Posts: 6543
Joined: Wed Jun 13, 2018 7:49 am

Re: Incrementing Value2 from Value1

Wed Oct 03, 2018 2:42 pm

Hello,

You're welcome. I am looking forward to hearing from you.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

ipollock
Posts: 137
Joined: Wed Aug 31, 2016 10:46 am

Re: Incrementing Value2 from Value1

Wed Oct 03, 2018 3:15 pm

Hi Catalin,

Thanks for your reply and examples. I used it to create the model and it works exactly as you explained.
I'll go ahead and use this in the installer i have.

Much appreciated.

Ian

Catalin
Posts: 6543
Joined: Wed Jun 13, 2018 7:49 am

Re: Incrementing Value2 from Value1

Wed Oct 03, 2018 3:17 pm

You're always welcome, Ian!

I am glad you got this working.

Kind regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”