Number in the value list

View: New views
4 Messages — Rating Filter:   Alert me  

Number in the value list

by Patrick Neame-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

FMP9A Mac OS X 10.5.5.

Dear all,

I have a value list with two names in it, Dave and Lucia. If the  
relevant field says Dave I want to define a script that sets it to  
Lucia and vice versa. The trouble is that until recently Lucia was  
Paul so the following won't work:-

If NameField = "Dave"
SetField(NameField; "Lucia")
Else
SetField(NameField; "Dave")
End if.

It won't work because every time we get a new house manager I'd have  
to go back to the script and change it and that's bad.

The script really needs to evaluate that the first name in the list  
has been checked and then to set the field to the second name. I  
haven't been able to find a function that will return a number based  
on which value in a value list has been checked. The field is a radio  
button set.

Many thanks,

Patrick.
_______________________________________________
FMPexperts mailing list
FMPexperts@...
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au

Re: Number in the value list

by Tom Elliott :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Patrick

Try a combination of GetValue() and ValueListItems() -

SetVariable [$vl ; ValueListItems ( Get ( filename ) ;  
"<valuelistname>" ]
If ( NameField = GetValue ( $vl ; 1 )
SetField [NameField ; GetValue ( $vl ; 2 )
Else
SetField [NameField ; GetValue ( $vl ; 1 )
End If

or, using your new friend :-) the Let function:

SetField [NameField ; <formula>]

where <formula> is:

Let (
        vl = ValueListItems ( Get ( filename ) ; "<valuelistname>" ) ;
        If ( NameField = GetValue ( $vl ; 1 ) ; GetValue ( $vl ; 2 ) ;  
GetValue ( $vl ; 1 ) )
      )

cheers

Tom


On 5 Oct 2008, at 7:43, Patrick Neame wrote:

> FMP9A Mac OS X 10.5.5.
>
> Dear all,
>
> I have a value list with two names in it, Dave and Lucia. If the  
> relevant field says Dave I want to define a script that sets it to  
> Lucia and vice versa. The trouble is that until recently Lucia was  
> Paul so the following won't work:-
>
> If NameField = "Dave"
> SetField(NameField; "Lucia")
> Else
> SetField(NameField; "Dave")
> End if.
>
> It won't work because every time we get a new house manager I'd have  
> to go back to the script and change it and that's bad.
>
> The script really needs to evaluate that the first name in the list  
> has been checked and then to set the field to the second name. I  
> haven't been able to find a function that will return a number based  
> on which value in a value list has been checked. The field is a  
> radio button set.
>
> Many thanks,
>
> Patrick.
> _______________________________________________
> FMPexperts mailing list
> FMPexperts@...
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au

_______________________________________________
FMPexperts mailing list
FMPexperts@...
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au

Re: Number in the value list

by Patrick Neame-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well, the let function is certainly more concise and it might indeed  
even be my new friend given that I'm starting to see how it works. I'm  
afraid the examples in the help file are a bit too abstract for bears  
of little brain.

One problem I did encounter was that the field is empty to start with.  
I added some stuff to the start of the script to set it to LeftValues  
1 of the ValueListitems (Dave in this case). What then happened is  
that if I then needed to change it to Lucia it would only do it on the  
second click of the button. The reason is that the first result  
includes the hidden pilcrow character. Once I'd realised what was  
going on and substituted it for "" everything was fine.

So the tooltip reads:-

Let(
VL= ValueListItems("Start";"HM");
If(PaperSignUp::HM= GetValue(VL;1);"Click here to enter¶" &  
GetValue(VL;2) & " as house manager.";"Click here to enter¶" &  
GetValue(VL;1) & " as house manager."
))

Many thanks.

On Oct 5, 2008, at 10:21 pm, Tom Elliott wrote:

> Patrick
>
> Try a combination of GetValue() and ValueListItems() -
>
> SetVariable [$vl ; ValueListItems ( Get ( filename ) ;  
> "<valuelistname>" ]
> If ( NameField = GetValue ( $vl ; 1 )
> SetField [NameField ; GetValue ( $vl ; 2 )
> Else
> SetField [NameField ; GetValue ( $vl ; 1 )
> End If
>
> or, using your new friend :-) the Let function:
>
> SetField [NameField ; <formula>]
>
> where <formula> is:
>
> Let (
>      vl = ValueListItems ( Get ( filename ) ; "<valuelistname>" ) ;
>      If ( NameField = GetValue ( $vl ; 1 ) ; GetValue ( $vl ; 2 ) ;  
> GetValue ( $vl ; 1 ) )
>    )
>
> cheers
>
> Tom
>
>
> On 5 Oct 2008, at 7:43, Patrick Neame wrote:
>
>> FMP9A Mac OS X 10.5.5.
>>
>> Dear all,
>>
>> I have a value list with two names in it, Dave and Lucia. If the  
>> relevant field says Dave I want to define a script that sets it to  
>> Lucia and vice versa. The trouble is that until recently Lucia was  
>> Paul so the following won't work:-
>>
>> If NameField = "Dave"
>> SetField(NameField; "Lucia")
>> Else
>> SetField(NameField; "Dave")
>> End if.
>>
>> It won't work because every time we get a new house manager I'd  
>> have to go back to the script and change it and that's bad.
>>
>> The script really needs to evaluate that the first name in the list  
>> has been checked and then to set the field to the second name. I  
>> haven't been able to find a function that will return a number  
>> based on which value in a value list has been checked. The field is  
>> a radio button set.
>>
>> Many thanks,
>>
>> Patrick.
>> _______________________________________________
>> FMPexperts mailing list
>> FMPexperts@...
>> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>
> _______________________________________________
> FMPexperts mailing list
> FMPexperts@...
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au

_______________________________________________
FMPexperts mailing list
FMPexperts@...
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au

Re: Number in the value list

by Tom Elliott :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Patrick

GetValue() returns only the text of a list value - without a final  
pilcrow - you might want to use this rather than LeftValues() and a  
Substitution (at the start of your script)

cheers

Tom

On 6 Oct 2008, at 11:01, Patrick Neame wrote:

> Well, the let function is certainly more concise and it might indeed  
> even be my new friend given that I'm starting to see how it works.  
> I'm afraid the examples in the help file are a bit too abstract for  
> bears of little brain.
>
> One problem I did encounter was that the field is empty to start  
> with. I added some stuff to the start of the script to set it to  
> LeftValues 1 of the ValueListitems (Dave in this case). What then  
> happened is that if I then needed to change it to Lucia it would  
> only do it on the second click of the button. The reason is that the  
> first result includes the hidden pilcrow character. Once I'd  
> realised what was going on and substituted it for "" everything was  
> fine.
>
> So the tooltip reads:-
>
> Let(
> VL= ValueListItems("Start";"HM");
> If(PaperSignUp::HM= GetValue(VL;1);"Click here to enter¶" &  
> GetValue(VL;2) & " as house manager.";"Click here to enter¶" &  
> GetValue(VL;1) & " as house manager."
> ))
>
> Many thanks.
>
> On Oct 5, 2008, at 10:21 pm, Tom Elliott wrote:
>
>> Patrick
>>
>> Try a combination of GetValue() and ValueListItems() -
>>
>> SetVariable [$vl ; ValueListItems ( Get ( filename ) ;  
>> "<valuelistname>" ]
>> If ( NameField = GetValue ( $vl ; 1 )
>> SetField [NameField ; GetValue ( $vl ; 2 )
>> Else
>> SetField [NameField ; GetValue ( $vl ; 1 )
>> End If
>>
>> or, using your new friend :-) the Let function:
>>
>> SetField [NameField ; <formula>]
>>
>> where <formula> is:
>>
>> Let (
>>     vl = ValueListItems ( Get ( filename ) ; "<valuelistname>" ) ;
>>     If ( NameField = GetValue ( $vl ; 1 ) ; GetValue ( $vl ; 2 ) ;  
>> GetValue ( $vl ; 1 ) )
>>   )
>>
>> cheers
>>
>> Tom
>>
>>
>> On 5 Oct 2008, at 7:43, Patrick Neame wrote:
>>
>>> FMP9A Mac OS X 10.5.5.
>>>
>>> Dear all,
>>>
>>> I have a value list with two names in it, Dave and Lucia. If the  
>>> relevant field says Dave I want to define a script that sets it to  
>>> Lucia and vice versa. The trouble is that until recently Lucia was  
>>> Paul so the following won't work:-
>>>
>>> If NameField = "Dave"
>>> SetField(NameField; "Lucia")
>>> Else
>>> SetField(NameField; "Dave")
>>> End if.
>>>
>>> It won't work because every time we get a new house manager I'd  
>>> have to go back to the script and change it and that's bad.
>>>
>>> The script really needs to evaluate that the first name in the  
>>> list has been checked and then to set the field to the second  
>>> name. I haven't been able to find a function that will return a  
>>> number based on which value in a value list has been checked. The  
>>> field is a radio button set.
>>>
>>> Many thanks,
>>>
>>> Patrick.
>>> _______________________________________________
>>> FMPexperts mailing list
>>> FMPexperts@...
>>> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>>
>> _______________________________________________
>> FMPexperts mailing list
>> FMPexperts@...
>> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
>
> _______________________________________________
> FMPexperts mailing list
> FMPexperts@...
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au

_______________________________________________
FMPexperts mailing list
FMPexperts@...
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
LightInTheBox - Buy quality products at wholesale price!