camposomar
Posts: 11
Joined: Sun Feb 06, 2011 4:12 am

Generate and Put Random Value

Hello All,

guys i need help for generate an put a random value in a edit box on dialog, i dont know how generate a value, and less how put inside of edit box, somebody can help me?

ty :)
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Generate and Put Random Value

Hi,

The solution would be to create a custom action that generates a random value and sets a public property in the installer with the result. You should add this custom action as an UI Custom Action from the Custom Actions Page. Then, from the Dialogs Page you should add a "DoAction" published event on the "Next" button from the dialog preceding the dialog that contains the edit box. Like mentioned in our user guide article, the "Property Name" field of the edit box should contain the name of the property set from the custom action.

To set a property from a VBScript custom action you can use this syntax:

Code: Select all

Session.Property("PROPERTY_NAME") = value
If you want to build a native C++ DLL your custom action, here is an example that contains the signature and also shows how to set an installer property.

Best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
camposomar
Posts: 11
Joined: Sun Feb 06, 2011 4:12 am

Re: Generate and Put Random Value

hello, thx for help..

I can't even make it work. :(

when run with log, can see don't return any value.. so i thing script have some wrong or the syntax is bad...is a JavaScript attached image

look log:

MSI (c) (34:9C) [21:10:31:649]: Doing action: randomnumber
Acción 21:10:31: randomnumber.
La acción se inició a las 21:10:31: randomnumber.
La acción terminó a las 21:10:31: randomnumber. Valor devuelto: 0.
MSI (c) (34:9C) [21:10:31:860]: Doing action: Registro
Acción 21:10:31: Registro.
Attachments
random.jpg
random.jpg (99.89 KiB) Viewed 4317 times
Bogdan
Posts: 2796
Joined: Tue Jul 07, 2009 7:34 am
Contact: Website

Re: Generate and Put Random Value

Hi,

Please note that you cannot place the result of your script in the return code of the custom action. The custom action will always return 0 if it was successful, any other value will be considered as
failure by Windows Installer. The solution is to create a script file (VBScript or JavaScript), in this file write the code to generate the random number, then store in a variable.
After this you need to set the value of the variable in the public property attached to the edit control, as in the VBScript example given by my colleague.

Regards,
Bogdan
Bogdan Mitrache - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”