Evaluate user input in custom dialog - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

m.ono
Posts: 14
Joined: Thu Feb 16, 2012 10:12 pm

Evaluate user input in custom dialog

Hey Y'all -

I am evaluating the advanced installer and I have the following issue I would like to get resolved:
The user is asked a e.g. username and a password which need to adhere to certain limitations e.g. a min and max length of the inputs.

I tried the following for the username field:
1. I use a global property name e.g. USERNAME in which I locate the username provided by the user via an edit control in a custom dialog.
2. I added a custom action that is called CheckUsernameLen with the script text:
Session.Property("USERNAME_LEN") = Len(Session.Property("USERNAME"))
3. In order to create the property USERNAME_LEN I added [USERNAME_LEN] to the field action data
4. Back in the custom dialog I added a DoAction event to the Published Event tab of the 'next'-button with the argument of my custom action CheckUsernameLen with the condition set to be true always. This action is the first in the list.
5. The NewDialog event is preceeded by another DoAction which is inteded to look at the USERNAME_LEN property and check if its value is e.g. less than 4 in which case another custom action is called which simply displays a message box (not the error message custom action!) telling the user that the username requires to be at least 5 characters: AI_INSTALL AND (USERNAME_LEN <= "4")

The result of this action if I try to simulate the dialog is that it prematurely ends the installation. I tracked down the issue the custom action where it checks the length of the username. It will successfully evalute its length since I can output it with a message box, but apparently I cannot write it back to the USERNAME_LEN property.

I hope you can help me out here! Maybe there is a fix for that or another way.

Thanks,
Martin

I am using:
Advanced Installer 8.9 (Trial)
Win 7, 64bit
Visual Studio Express 2010 + Windows SDK + SP1
Last edited by m.ono on Tue Feb 21, 2012 3:14 am, edited 1 time in total.
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Evalute user input in custom dialog

Hi Martin and welcome to Advanced Installer forums,
3. In order to create the property USERNAME_LEN I added [USERNAME_LEN] to the field action data
As described in the following article, the action data field is useful when passing public property values to deferred custom actions in InstallExecuteSequence:
http://www.advancedinstaller.com/user-g ... rties.html

You can easily declare a public property in the Install Parameters page and this is what you should try:
http://www.advancedinstaller.com/user-g ... eters.html

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
m.ono
Posts: 14
Joined: Thu Feb 16, 2012 10:12 pm

Re: Evalute user input in custom dialog

Thanks Mihai for your quick reply!
I tried your solution before, where I created a public property with a default value. I even tried it by using a hidden edit field with the property named USERNAME_LEN in the same dialog.
All of the solutions resulted in a premature exit of the installer.
I think it fails when I try to write to the public property using this command:
Session.Property("USERNAME_LEN") = Len(Session.Property("USERNAME"))

So my question remains: how can I verify that the user's input is according to my requirements?

Thanks for your help!
Martin
m.ono
Posts: 14
Joined: Thu Feb 16, 2012 10:12 pm

Re: Evalute user input in custom dialog

Attached is an AIP-file that demonstrates the issue I am describing.

Thanks,
Martin
Attachments
TestInterface.aip
AIP to demonstrate the issue in this thread.
(11.61 KiB) Downloaded 648 times
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Evaluate user input in custom dialog

Hi,

The Len function is outputting a number, so you need to convert it to a string before saving it in a property. For example:

Code: Select all

Session.Property("MY_USERNAME_LEN") = CStr(Len(Session.Property("MY_USERNAME")))
I tested it on your project and it works. Please note that because of a Windows Installer limitation, the edit boxes are not updated immediately after changing their properties. But if you press Back and then Next to show the dialog again, you will see the updated value.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
m.ono
Posts: 14
Joined: Thu Feb 16, 2012 10:12 pm

Re: Evaluate user input in custom dialog

Thanks Cosim -

That helped!
One additional remark. If one would like to check the length against a minimum or maximum numbers use the '<' and '>' operators and do not use quotation marks with the limits e.g. a condition would look like:
(USERNAME_LEN > 5) AND (USERNAME_LEN < 65)

Thanks again!
Martin
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Evaluate user input in custom dialog

Hi Martin,

Unfortunately the comparative operators will handle strings( ASCII table ) not integer values. A solution is to do the comparison using integer values within a custom action and work with the return value.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”