Announcement

Collapse
No announcement yet.

Checkbox Default Value

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Checkbox Default Value

    Hi

    I need to insert a value of True or False into an XML settings file dependent upon the state of a checkbox on one of the dialogues in my MSI Factory Project. I very quickly set up Property CIP Value when the checkbox is checked True in the settings page of the checkbox properties and this enabled me to correctly insert True into the Xml Settings File. But I can't figure out how to set CIP property to False if the checkbox is unchecked. Any advice greatly appreciated.

    Many Thanks

  • #2
    You could use a Custom Action (LuaScript) and see if the Property set by the Checkbox is defined or not.

    Ulrich

    Comment


    • #3
      Thanks for that. lua scripts are completely new to me so please can you give more detail of how to achieve this. After quick google search I guess the script should be something like if CIP <> "True" CIP = "False" end. But where and how do I plug the script into the installer project?

      Comment


      • #4
        In MSI Factory, you would use Custom Actions > Add > Run LuaScript. Then you would create a new script, checking for the existence of the Property set by the Checkbox, and use the XML actions to set the value as desired in the XML file. Every Lua action is documented in the help file, and comes with at least one script sample.

        If you are uncomfortable writing a script in Lua, you could also create two XML actions. Use XML > Add > Configure XML, and create one action to set the field to "true", and another one where the only difference is that the value for the field is set to "false". Then open the Component Manager, and set a Condition on each of these actions, so only one can be executed. For example, you could adjust the Checkbox so that the Property name it controls is THE_CHECKBOX_PROPERTY, and it is set to 1 if checked (the value really doesn't matter). The Condition on the first XML action would simply be THE_CHECKBOX_PROPERTY, which means that, if THE_CHECKBOX_PROPERTY is defined, the XML action will be performed. On the second XML action, set the Condition as NOT THE_CHECKBOX_PROPERTY, so if the Checkbox was not checked, this Property won't be set (it doesn't exist) and the Condition will be satisfied, triggering the execution of that XML action instead.
        Click image for larger version

Name:	SCRN-2014-03-28-01.png
Views:	1
Size:	45.9 KB
ID:	284177
        Ulrich

        Comment


        • #5
          Thanks for your response. I got this working using the two XML updates you suggested. One day I'll figure out how to do it using LuaScript.

          Comment

          Working...
          X