Newbies ebruml Posted September 11, 2012 Newbies Posted September 11, 2012 I have a script on a button that currently clears the content of a field. Can any one please explain how I could adapt the script so that I use the same script Ie. clear but the field clears depends on the parameter. For example I want button A (with script parameter for example "A") to clear the contents of field A, while button B (with script parameter for example "B") to clear the contents of field B, and button C (with script parameter for example "C") to clear the contents of field C. Any help much appreciated. Thanks
bcooney Posted September 11, 2012 Posted September 11, 2012 The key is the receiving of the parameter using the Get (Scriptparameter) step to branch accordingly. I realize you're providing a simple example, and so (pseudo-code): If (Get (Scriptparameter) = "A" Set Field A = "" ElseIf (Get (Scriptparameter) = "B" do this Else do this End If
Lee Smith Posted September 11, 2012 Posted September 11, 2012 I'm not sure if this is what you mean, but check out my file attached to this thread AlphaButtons. Go into Layout Mode, and select the buttons. You will need to ungroup them, and then look at the script steps. Lee
jbante Posted September 11, 2012 Posted September 11, 2012 Another possible script approach might be to use the Set Field By Name [] script step. The script parameter could be: GetFieldName ( Table::field ) ... and the script could be as simple as one step: Set Field By Name [Get ( ScriptParameter ); ""] This way, if you change the names of any fields, you wont have to change the script parameter or the conditions in the If [] statements in bcoony's example to match. Changing field names wouldn't actually cause bcooney's sample to stop working if you left the script and parameters alone, but this way the parameter name and the actual field name always match (it can be confusing months later when they don't), and you don't have to modify the script when you need it to accomodate additional fields. If there are only some fields you want the script to clear, or only some fields you want the script to not clear, you could compare the parameter against a whitelist or blacklist (respectively) of fields to act on: Set Variable [$fieldWhiteList; Value: List ( GetFieldName ( Table::A ) ; GetFieldName ( Table: ) ... ] If [/* Field specified by parameter is in the white list */ Position ( ¶ & $fieldWhiteList & ¶ ; ¶ & Get ( ScriptParameter ) & ¶ ; 1 ; 1 ) > 0 )] Set Field By Name [Get ( ScriptParameter ); ""] End If
Recommended Posts
This topic is 4525 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now