Field name as a parameter

Field name as a parameter

am 19.01.2008 03:13:27 von Vandar

I have ten individual checkbox fields, each with a single identical
value ("1").

I want to place an invisible button over each checkbox that, when
clicked, will execute a script that toggles the checkbox. I'd like each
button to execute the same script, with the field name to toggle passed
to the script as a variable.
In effect, what I'm looking for is a way for SetField (or a similar
step) to have the field name parameter passed as a variable.

Can this be done? Am I missing the obvious?
Assistance, advice, solutions, and large sums of cash are all
appreciated. Thanks.

Re: Field name as a parameter

am 19.01.2008 03:31:00 von Lynn Allen

On 2008-01-18 18:13:27 -0800, Vandar said:

> I have ten individual checkbox fields, each with a single identical
> value ("1").
>
> I want to place an invisible button over each checkbox that, when
> clicked, will execute a script that toggles the checkbox. I'd like each
> button to execute the same script, with the field name to toggle passed
> to the script as a variable.
> In effect, what I'm looking for is a way for SetField (or a similar
> step) to have the field name parameter passed as a variable.
>
> Can this be done? Am I missing the obvious?
> Assistance, advice, solutions, and large sums of cash are all
> appreciated. Thanks.

To use a single script without parameters would mean being able to use
Get(ActiveFieldName) which you cannot do unless the cursor is actually
IN the field.

However, what you can do is put a different hard-coded script parameter
on each button when assigning the script (1, 2, 3 will do, but you can
use text values or field names as well). In your script, capture the
script parameter with Get(ScriptParameter) and then give alternate
choices based on the parameter. For each possible choice you can set a
different field to be toggled.

The ElseIf step works well when you have lots of possible choices. And
using the calculation Abs(Fieldname -1) means you don't have to test to
see if the field is checked or not, it'll just toggle to the opposite
value.
--
Lynn Allen
--
www.semiotics.com
Member Filemaker Business Alliance
Long Beach, CA

Re: Field name as a parameter

am 19.01.2008 03:33:13 von Jens Teich

Vandar writes:

> In effect, what I'm looking for is a way for SetField (or a similar
> step) to have the field name parameter passed as a variable.

SetField can't write in a field with variable name.

But if you use one field with repetitions, these can be called by
parameter.


-jens

Re: Field name as a parameter

am 19.01.2008 04:32:38 von Vandar

Lynn Allen wrote:

> On 2008-01-18 18:13:27 -0800, Vandar said:
>
>> I have ten individual checkbox fields, each with a single identical
>> value ("1").
>>
>> I want to place an invisible button over each checkbox that, when
>> clicked, will execute a script that toggles the checkbox. I'd like
>> each button to execute the same script, with the field name to toggle
>> passed to the script as a variable.
>> In effect, what I'm looking for is a way for SetField (or a similar
>> step) to have the field name parameter passed as a variable.
>>
>> Can this be done? Am I missing the obvious?
>> Assistance, advice, solutions, and large sums of cash are all
>> appreciated. Thanks.
>
>
> To use a single script without parameters would mean being able to use
> Get(ActiveFieldName) which you cannot do unless the cursor is actually
> IN the field.
>
> However, what you can do is put a different hard-coded script parameter
> on each button when assigning the script (1, 2, 3 will do, but you can
> use text values or field names as well). In your script, capture the
> script parameter with Get(ScriptParameter) and then give alternate
> choices based on the parameter. For each possible choice you can set a
> different field to be toggled.

I did think of If statements, but I was wondering if there was some way
to avoid such a method - a three or four line script that could perform
the same function with a different parameter passed to it from each button.
I'm always looking for more intuitive and efficient methods and yours
does fit that criteria, so thanks.

> The ElseIf step works well when you have lots of possible choices. And
> using the calculation Abs(Fieldname -1) means you don't have to test to
> see if the field is checked or not, it'll just toggle to the opposite
> value.

I actually knew that, but I haven't reached that point yet, so those
synapses didn't connect when I wrote the above.
Thanks again.

Re: Field name as a parameter

am 19.01.2008 07:40:59 von Lynn Allen

On 2008-01-18 19:32:38 -0800, Vandar said:

> I did think of If statements, but I was wondering if there was some way
> to avoid such a method - a three or four line script that could perform
> the same function with a different parameter passed to it from each
> button.

Every new version of FM, I think some new function might give that "set
field dynamically" functionality, and then it doesn't.

It's a feature request that's been made repeatedly, stridently, for at
least 10 years.
--
Lynn Allen
--
www.semiotics.com
Member Filemaker Business Alliance
Long Beach, CA

Re: Field name as a parameter

am 19.01.2008 15:08:12 von Robert Chapman

I've come across the frustration again recently...

In some cases though, you can get by with a Goto Object [fieldname] (which
*can* be calculated :-)
and a Set Field with an empty field parameter.

Thankfully, that was the case for me :-)
----- Original Message -----
From: Lynn Allen
Newsgroups: comp.databases.filemaker
Sent: Saturday, January 19, 2008 7:40 AM
Subject: Re: Field name as a parameter


On 2008-01-18 19:32:38 -0800, Vandar said:

Every new version of FM, I think some new function might give that "set
field dynamically" functionality, and then it doesn't.

It's a feature request that's been made repeatedly, stridently, for at
least 10 years.

Re: Field name as a parameter

am 19.01.2008 15:29:29 von Robert Chapman

BTW: for Goto Object [fieldname], of course the [fieldname] is not the field
name, but the object name you gave the field.

"Robben" schreef in bericht
news:gvnkj.36084$O62.3646572@phobos.telenet-ops.be...
> I've come across the frustration again recently...
>
> In some cases though, you can get by with a Goto Object [fieldname] (which
> *can* be calculated :-)
> and a Set Field with an empty field parameter.