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

How to use "Checkbox set" in script

9 views
Skip to first unread message

leon....@iae.nl

unread,
Aug 3, 2005, 9:32:20 AM8/3/05
to
Hello,

In a record I do use a field with several text options that can be set
as "X" or "empty" of the used "Checkbox set".

How to use "Checkbox set" within a script, so I can check or uncheck
the box automatically (e.g. for a found set by using loop function).
Also how to use the script when the second or third checkbox has to be
set.

Thanks in advise.
Regards, Leon Obers

Dan

unread,
Aug 3, 2005, 11:46:50 AM8/3/05
to

The checkbox being set puts the text option into the field, multi-checks
put the options separated by carriage returns. So to get the checkbox to
show x you have to put the appropriate text option into the field. If
you want to keep the existing field contents (for multi-checked case)
then do a SetField which includes the original field & "ś" & the new
option.

--
Dan
Using
FMP7.03, WinXP SP2


Léon Obers

unread,
Aug 4, 2005, 6:14:38 PM8/4/05
to

Dan wrote:

> leon....@iae.nl wrote:

>>In a record I do use a field with several text options that can be set
>>as "X" or "empty" of the used "Checkbox set".

>>How to use "Checkbox set" within a script, so I can check or uncheck
>>the box automatically (e.g. for a found set by using loop function).
>>Also how to use the script when the second or third checkbox has to be
>>set.

> The checkbox being set puts the text option into the field, multi-checks

> put the options separated by carriage returns. So to get the checkbox to
> show x you have to put the appropriate text option into the field. If
> you want to keep the existing field contents (for multi-checked case)
> then do a SetField which includes the original field & "ś" & the new
> option.

I have tried to find out what you mean and how to use it in a script,
but unfortunately I don't understand.

Can you give examples how to change the value of the "check" within a
script, and wich functions to use?

Fieldname: "Order"
Text as set within a "Checkbox set" (in checked mode):

X Packed
X Send


--
Vr.groet - regards, Léon Obers

Reacties per mail, vervang "invalid" door "cc" in het adres.
Reactions by mail, exchange "invalid" by "cc" within address.

Dan

unread,
Aug 4, 2005, 9:36:30 PM8/4/05
to
Léon Obers wrote:
> Dan wrote:
>
>> leon....@iae.nl wrote:
>
>>> In a record I do use a field with several text options that can be
>>> set as "X" or "empty" of the used "Checkbox set".
>
>>> How to use "Checkbox set" within a script, so I can check or uncheck
>>> the box automatically (e.g. for a found set by using loop function).
>>> Also how to use the script when the second or third checkbox has to
>>> be set.
>
>> The checkbox being set puts the text option into the field,
>> multi-checks put the options separated by carriage returns. So to
>> get the checkbox to show x you have to put the appropriate text
>> option into the field. If you want to keep the existing field
>> contents (for multi-checked case) then do a SetField which includes
>> the original field & "ś" & the new option.
>
> I have tried to find out what you mean and how to use it in a script,
> but unfortunately I don't understand.
>
> Can you give examples how to change the value of the "check" within a
> script, and wich functions to use?
>
> Fieldname: "Order"
> Text as set within a "Checkbox set" (in checked mode):
>
> X Packed
> X Send

OK This is a script to which you pass a parameter "On" or "Off" . I am
writing it with a field Order for the Checkboxes and a field Value
containing the value. You can replace Value throughout with a constant
text string like "packed". I will confess it is a bit trickier than I
though, particularly removing a check but I have tested this and it
seems to work OK The outer If and Else if is just picking up the On or
Off parameters, The first inner if End If checks that the value is not
there already before adding it. The seconf inner If End If makes sure it
is there before trying to remove it.

If[Get(ScriptParameter)="On"]
If[PatternCount(Order;Value)=0]
SetField[Order;Order & Value & "ś"
End If
Else If[Get(ScriptParameter)="Off"]
If[PatternCount(Order;Value) > 0]
SetField[Order;Replace (Order;
Position(Order;Value;0;1);Length(Value)+1;"" )
End If
End If

Helpful Harry

unread,
Aug 5, 2005, 3:22:43 AM8/5/05
to
In article <dcu40b$got$1...@news5.zwoll1.ov.home.nl>, Léon Obers
<mail....@fotograaf.invalid> wrote:

> I have tried to find out what you mean and how to use it in a script,
> but unfortunately I don't understand.
>
> Can you give examples how to change the value of the "check" within a
> script, and wich functions to use?
>
> Fieldname: "Order"
> Text as set within a "Checkbox set" (in checked mode):
>
> X Packed
> X Send

"Checkbox" fields are simply normal text fields that store the values
that are checked, each spearated by a return character (ś). The best
way to see how they work is to duplicate the checkbox field on a lyout
and change its formatting back to "normal" field - then playing with
the values of the checkbox version in browse mode will show you how
FileMaker sets the fields real data in the "normal" version.

To turn on a checkbox you simply add that value to the field's existing
data, making sure to include the return character (ś) that check box
fields use to separate values. It's best to use the Position or
PatternCount function to first to test that the value isn't already
checked.
eg.
If [Position(CheckBoxField, "Packed", 1, 1) = 0]
Set Field [CheckBoxField, CheckBoxField & "śPacked"]
End If

If [Position(CheckBoxField, "Sent", 1, 1) = 0]
Set Field [CheckBoxField, Checkboxfield & "śSent"]
End If

To turn off a checkbox you need to remove that value from the field's
existing data, but leaving everything else. It's not as important to
test that the value is already on since the Substitute function won't
do anything if the value doesn't exist. You also need an extra
Substitute command to remove possible double-return characters
left-over by removing the value.
eg.

Set Field [CheckBoxField,
Substitute(
Substitute (CheckBoxField, "Packed", ""),
"śś", "ś"]

Set Field [CheckBoxField,
Substitute(
Substitute (CheckBoxField, "Sent", ""),
"śś", "ś"]


Those will work, but they aren't "tidy" methods. For example, turning
on and then off one single value will leave behind one return
character, but that doesn't really matter if the field only ever uses
Checkbox formatting.


There is also a problem here if you use values in your Value List where
one is a sub-set of another. For example a Value List containing both

Option 1
and Option 12

will have problems since the substitute function trying to turn off
"Option 1" will also change "Option12" to "2", resulting in "Option 12"
also being turned off (and the field containing an invisible "2" when
using Checkbox formatting). It will cause problems for the Position /
PatternCount function when turning on a checkbox.


Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)

Dan

unread,
Aug 5, 2005, 4:30:35 AM8/5/05
to

I tested this a bit more this morning and there are problems if you
allow users to click the checkboxes before scripting them because a
single checked box does not have a carriage return in the field. This
problem can be resolved by changing the order of concatenation in the
first SetField

SetField[Order;Value & "ś" & Order]

Harry's solution avoids this problem by putting the carriage return at
the front but then when removing a check then, as he has done, it is
necessary to check for double carriage returns.

Helpful Harry

unread,
Aug 5, 2005, 7:50:56 PM8/5/05
to
In article <LuidnZKLC6o...@brightview.com>, "Dan"
<d...@owlsnet.co.uk> wrote:

My method has the problem of leaving a single carriage return if you
turn off all the options (after turning on one or more) - but it's
usually not a problem, unless you're using a normal version of the
field in a printed report ... even then sliding may get rid of it
anyway, but I haven't "checked" that. ;o)

Léon Obers

unread,
Aug 5, 2005, 8:26:24 PM8/5/05
to

As also written to Harry, I do appreciate your suggestions and help very
greatly.

Next morning I am packing for holiday and leaving sunday to Scotland.
Taking your and Harry's suggestions with me, together with my notebook.
When I am not drinking too much Scottish MALT, there is a possibility
that my brainfunctions still are in good condition to work out yours and
Harry's suggestions (after my wife and daughter's care are fulfilled
first).

About a week or 2-3 I shall be back, and shall give report to you and
Harry what I have made of your suggestions.

Thanks for all the help and time already spended to this question.
This newsgroup is a great help in general for making better applications.

I'll be back.


Dan wrote:

>>If[Get(ScriptParameter)="On"]
>> If[PatternCount(Order;Value)=0]
>> SetField[Order;Order & Value & "ś"
>> End If
>>Else If[Get(ScriptParameter)="Off"]
>> If[PatternCount(Order;Value) > 0]
>> SetField[Order;Replace (Order;
>>Position(Order;Value;0;1);Length(Value)+1;"" )
>> End If
>>End If
>
>
> I tested this a bit more this morning and there are problems if you
> allow users to click the checkboxes before scripting them because a
> single checked box does not have a carriage return in the field. This
> problem can be resolved by changing the order of concatenation in the
> first SetField
>
> SetField[Order;Value & "ś" & Order]
>
> Harry's solution avoids this problem by putting the carriage return at
> the front but then when removing a check then, as he has done, it is
> necessary to check for double carriage returns.


--

Léon Obers

unread,
Aug 5, 2005, 8:26:33 PM8/5/05
to

Helpful Harry wrote:
> Léon Obers wrote:

>>I have tried to find out what you mean and how to use it in a script,
>>but unfortunately I don't understand.
>>
>>Can you give examples how to change the value of the "check" within a
>>script, and wich functions to use?
>>
>>Fieldname: "Order"
>>Text as set within a "Checkbox set" (in checked mode):
>>
>>X Packed
>>X Send
>
>
> "Checkbox" fields are simply normal text fields that store the values
> that are checked, each spearated by a return character (ś). The best
> way to see how they work is to duplicate the checkbox field on a lyout
> and change its formatting back to "normal" field - then playing with
> the values of the checkbox version in browse mode will show you how
> FileMaker sets the fields real data in the "normal" version.

This is a great help for the understanding of the function.
Reading yours and Dan's message for start, I think I can manage the
function and the background working.

At this moment I want to skip further detail.
Next morning I have to pack for holiday, leaving sunday to Scotland.
I shall take my notebook with me, and when the evenings are wett and
dark, I think there is a possibility that I shall study your and Dan's
suggestions drinking a tasty Scottisch Malt.

This newsgroup is very informative and helpfully to solve all sort of
Filemaker questions. With the help of this newsgroup I have managed
already a much better working of my applications.

About a week or 2-3 I shall be back, and shall give report to you and

Dan what I have made of your suggestions.

Thanks for all the help. Till I'll be back.

Léon Obers

unread,
Aug 5, 2005, 8:31:40 PM8/5/05
to

Helpful Harry wrote:

> My method has the problem of leaving a single carriage return if you
> turn off all the options (after turning on one or more) - but it's
> usually not a problem, unless you're using a normal version of the
> field in a printed report ...

No, in this version of my application, it is only a screen usage menu to
fill in data, and to work with much buttons to automate tasks.

But a good warning what I can expect by making other work-arounds.

Thanks.

Helpful Harry

unread,
Aug 6, 2005, 2:47:43 AM8/6/05
to
In article <dd10d7$uu9$1...@news5.zwoll1.ov.home.nl>, Léon Obers
<mail....@fotograaf.invalid> wrote:

> Helpful Harry wrote:
>
> > My method has the problem of leaving a single carriage return if you
> > turn off all the options (after turning on one or more) - but it's
> > usually not a problem, unless you're using a normal version of the
> > field in a printed report ...
>
> No, in this version of my application, it is only a screen usage menu to
> fill in data, and to work with much buttons to automate tasks.
>
> But a good warning what I can expect by making other work-arounds.

Another method for a checkbox field is to separate them into individual
fields for each option, with all fields using a simple value list of
"Yes" (or "On").

Put the field on the layout, but shrink it so you can't see the "Yes"
value. Then use the text tool to type on what you want the label to
read next to the box. You end up with something like:

[ ] Packed <--- PackedField {value list "Yes"}
[ ] Sent <--- SentField {value list "Yes"}

Now you can use the rectangle tool to draw a small square over each
checkbox and define them to run two scripts (or perhaps one script in
FileMaker 7 which passes a parameter to the script) which simply
toggles the field between "Yes" and empty.

PACKED BUTTON
If [PackedField = "Yes", "", "Yes"]

SENT BUTTON
If [SentField = "Yes", "", "Yes"]

In this case there's no need to worry about carriage returns or the
value for one option also being part of another value. :o)

Léon Obers

unread,
Aug 6, 2005, 6:33:22 PM8/6/05
to

Helpful Harry wrote:

> Another method for a checkbox field is to separate them into individual
> fields for each option, with all fields using a simple value list of
> "Yes" (or "On").
>
> Put the field on the layout, but shrink it so you can't see the "Yes"
> value. Then use the text tool to type on what you want the label to
> read next to the box. You end up with something like:
>
> [ ] Packed <--- PackedField {value list "Yes"}
> [ ] Sent <--- SentField {value list "Yes"}

(Before the day I go for holiday).
This method is exactly the method I made already within my application.
Even a more wide use by making two buttons.
One button showing an ">",
in the middle a square field containg X when a button is pushed or just
empty. At the right a button with double ">>"

> X >>

Pushing the left button, do copy an "X" into the field of the active
record. Pushing again it empties.

Pushing the right button, the same as above, but for the complete found
set of records. (So with a loop function in it).

Yesterday evening reading all the suggestions, I was considering if it
is worth the try of your more early suggestions, as this last method is
much more easy. With some extra "tricks" you can even use the same
script for several tables depending to the layout (and used table).

(This is probably the last message till I am back of holiday. So till
2-3 weeks.)

0 new messages