Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Revert modification on a checkbox after a script

60 views
Skip to first unread message

Jack

unread,
Aug 19, 2012, 8:49:02 AM8/19/12
to
Hi,

I have a checkbox (field in the table will be 1 if [X] or "" if []) with
a script trigger on modification.

The script has a dialog box (OK or Cancel).

I want that if the user click on cancel the chckbox revert as before is
modified.

For example if checkbox has [X], if I press and say OK in the dialog box
the checkbox will be [].
If checkbox has [X], if I press and say Cancel in the dialog box the
checkbox will stay [X].

How can I do that?

Thanks Bye Jack
--
Yoda of Borg am I! Assimilated shall you be! Futile resistance is, hmm?

E. Appeldoorn

unread,
Aug 19, 2012, 9:40:14 AM8/19/12
to
make the checkbox-field be a value that accepts either 1 and 0
(don't make it 1 and empty as you suggested)

Basic layout of script:

display dialog [change or revert or something like that message]
if pressed Revert
set field [checkboxfield ; not (checkboxfield)]
end if


It will revert back to the previous value when pressed the revert button
in other words when the user changed an on (value of 1) into off (value of
0) it will revert the 0 to 1
In the other case the script will exit and the value will left to the
changed value.

Personally I wouldn't use a scripttrigger for this. I would disable the
field and lay an invisible button on top of the field. This button would
then fire the scipt.
The value wouldn't change at all until the user gives the feedback to the
script. Which would be safer because nothing would happen if by accident the
script gets halted before the user made a choice.
(like shutting down filemaker, or the whole computer)

Keep well, Ursus


Jack" schreef in bericht news:1kp2wvk.1jjwa4q1bth668N%pip...@disney.com...

Jack

unread,
Aug 19, 2012, 12:40:23 PM8/19/12
to
E. Appeldoorn <ursus...@ziggo.nl> wrote:

> make the checkbox-field be a value that accepts either 1 and 0
> (don't make it 1 and empty as you suggested)
>
> Basic layout of script:
>
> display dialog [change or revert or something like that message]
> if pressed Revert
> set field [checkboxfield ; not (checkboxfield)]
> end if

clever

> Personally I wouldn't use a scripttrigger for this. I would disable the
> field and lay an invisible button on top of the field. This button would
> then fire the scipt.
> The value wouldn't change at all until the user gives the feedback to the
> script. Which would be safer because nothing would happen if by accident the
> script gets halted before the user made a choice.
> (like shutting down filemaker, or the whole computer)

yes, probably better this way.

Thank you

Helpful Harry

unread,
Aug 19, 2012, 5:07:14 PM8/19/12
to
In article <1kp37sl.1myidovxtjybiN%pip...@disney.com>, pip...@disney.com
(Jack) wrote:

> E. Appeldoorn <ursus...@ziggo.nl> wrote:
>
> > make the checkbox-field be a value that accepts either 1 and 0
> > (don't make it 1 and empty as you suggested)
> >
> > Basic layout of script:
> >
> > display dialog [change or revert or something like that message]
> > if pressed Revert
> > set field [checkboxfield ; not (checkboxfield)]
> > end if
>
> clever

That is a neat way of changing an "on" / "off" checkbox field (called a
Boolean field in databases and programming languages that natively support
it).

Another neat method that someone else posted quite a while back is:

Set Field [Checkboxfield; ABS(Checkboxfield - 1)]

to swap between values of 0 and 1.





> > Personally I wouldn't use a scripttrigger for this. I would disable the
> > field and lay an invisible button on top of the field. This button would
> > then fire the scipt.
> > The value wouldn't change at all until the user gives the feedback to the
> > script. Which would be safer because nothing would happen if by accident the
> > script gets halted before the user made a choice.
> > (like shutting down filemaker, or the whole computer)
>
> yes, probably better this way.

That's the best way.

If you wanted to still use a Scripttrigger, then another (long-winded) way
could be to have a second Field called Checkboxfield_OLD that stores a
copy of the current allowed value. Then the pseudo-script would be
something like:

Display Message ["Do you want to change this value?"]
If [MessageChoice = "OK"]
Set Field [Checkboxfield; Not(Checkboxfield)]
Set Field [Checkboxfield_OLD; Checkboxfield]
Else
Set Field [Checkboxfield; Checkboxfield_OLD]
End If

If the user says "OK", then the changed value is copied into
Checkboxfield_OLD. If the user says "Cancel" then the previous value is
coped from Checkboxfield_OLD back into Checkboxfield.


Helpful Harry :o)
0 new messages