dbTalk Databases Forums  

How to use "Checkbox set" in script

comp.databases.filemaker comp.databases.filemaker


Discuss How to use "Checkbox set" in script in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
leon.obers@iae.nl
 
Posts: n/a

Default How to use "Checkbox set" in script - 08-03-2005 , 08:32 AM






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


Reply With Quote
  #2  
Old   
Dan
 
Posts: n/a

Default Re: How to use "Checkbox set" in script - 08-03-2005 , 10:46 AM






leon.obers (AT) iae (DOT) nl wrote:
Quote:
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
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




Reply With Quote
  #3  
Old   
Léon Obers
 
Posts: n/a

Default Re: How to use "Checkbox set" in script - 08-04-2005 , 05:14 PM





Dan wrote:

Quote:
leon.obers (AT) iae (DOT) 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.



Reply With Quote
  #4  
Old   
Dan
 
Posts: n/a

Default Re: How to use "Checkbox set" in script - 08-04-2005 , 08:36 PM



Léon Obers wrote:
Quote:
Dan wrote:

leon.obers (AT) iae (DOT) 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



--
Dan
Using
FMP7.03, WinXP SP2




Reply With Quote
  #5  
Old   
Helpful Harry
 
Posts: n/a

Default Re: How to use "Checkbox set" in script - 08-05-2005 , 02:22 AM



In article <dcu40b$got$1 (AT) news5 (DOT) zwoll1.ov.home.nl>, Léon Obers
<mail.to.me (AT) fotograaf (DOT) invalid> wrote:

Quote:
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)


Reply With Quote
  #6  
Old   
Dan
 
Posts: n/a

Default Re: How to use "Checkbox set" in script - 08-05-2005 , 03:30 AM



Dan wrote:
Quote:
Léon Obers wrote:
Dan wrote:

leon.obers (AT) iae (DOT) 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
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.


--
Dan
Using
FMP7.03, WinXP SP2




Reply With Quote
  #7  
Old   
Helpful Harry
 
Posts: n/a

Default Re: How to use "Checkbox set" in script - 08-05-2005 , 06:50 PM



In article <LuidnZKLC6opvm7fRVnytQ (AT) brightview (DOT) com>, "Dan"
<dan (AT) owlsnet (DOT) co.uk> wrote:

Quote:
Dan wrote:
Léon Obers wrote:
Dan wrote:

leon.obers (AT) iae (DOT) 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

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.
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)



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


Reply With Quote
  #8  
Old   
Léon Obers
 
Posts: n/a

Default Re: How to use "Checkbox set" in script - 08-05-2005 , 07:26 PM




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:

Quote:
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.

--
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.



Reply With Quote
  #9  
Old   
Léon Obers
 
Posts: n/a

Default Re: How to use "Checkbox set" in script - 08-05-2005 , 07:26 PM





Helpful Harry wrote:
Quote:
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.




--
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.



Reply With Quote
  #10  
Old   
Léon Obers
 
Posts: n/a

Default Re: How to use "Checkbox set" in script - 08-05-2005 , 07:31 PM





Helpful Harry wrote:

Quote:
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.

--
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.



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.