One script to manage a process


One of the most common script patterns that I use is when I have a process with a number of actions. In many cases this is a script to manage a particular entity. So actions can be any of Open, Add, Edit, Save, Cancel and Exit.

Each action will perform a discrete series of script steps. For example, the Open action may open the current record in a card window; the Add action may open the same card window and create a new record.

This pattern means that all buttons associated with the process run the same script with a different parameter (action).

This centralises the process actions. It also makes it very easy to update and add to specific actions associated with a specific process.

The general structure of the script is:


# assign to buttons to perform specific actions
# Parameter: action - name of a specific task
Set Variable [ $action; Value: Get(ScriptParameter)]
If [ IsEmpty ( $action ) ]
  Show Custom Dialog [ "Error" ; 
    "No action (parameter) provided." ]
Else If [ $action = "one" ]
Else If [ $action = "two" ]
Else If [ $action = "three" ]
Else If [ $action = "four" ]
Else
  Show Custom Dialog [ "Error" ; 
    "Invalid action (parameter) provided." ]
End If

When the actions are specified, you simply add the required script steps in the Else If block.

For more complex processes, you may decide to use this script as a "dispatcher". This would mean an action is handed off to another script using Perform Script.

Do you use a similar structure in your scripting?


Are you coming to Reconnect.Christchurch, 15-16 October?
Get all the details and purchase tickets at Reconnect.Christchurch.

Are you late to the ScriptLogic party? If you have missed out on some of these emails, catch up here: Email Archive

If you know someone else who you think might like this email, you can send them this link to subscribe: Subscribe to ScriptLogic Daily