Jump to content

Script for Next/Prev Value List Item Possible?


Conner
 Share

This topic is 5645 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi, all!

Set up:

I have a Pop-up Menu Field that displays values from a Value List, a list of employees in this case.

Below that is a Portal that displays various data about the selected employee.

Need:

I'd like to have an "Next" button and "Previous" button to the left and right of the Pop-up field that activates a script to go to the next/prev. employee in the Value List. Is this possible?

Link to comment
Share on other sites

Hi, Conner!

Yes, you can do it by script using ValueListItems() function

First you mast have calc field which = ValueListItems()

Then in this field you must choose the next or priview word(of current) and put it to your field which is Pop_Up menu.

Link to comment
Share on other sites

  • 3 weeks later...

Okay, I have the pop_up field that shows one of the names from the Value List and the calc field that shows all the names from the Value List via the ValueListItems function.

I'm not clear on how I choose the next or prev. name from the calc field. Because it shows all the names, I don't know how to select only one to put it into the pop_up field.

-Conner

Link to comment
Share on other sites

I do not have my FM8 copy handy here, so let me explain this in FMP6 speak.

I would create a global text field. Then populate it by a scripted value. The value would have to be on the basis of text parsing. Are you familiar with how to do that, or do you want me to send you an example?

Link to comment
Share on other sites

Use the value function:

Value( "ValueList" ; n )

where n is the value number you want pulled out in your value list. Using this you could just set n to be + 1 or -1 using your prev next buttons and return the correct value in a calc or something using the function mentioned above.

EDIT... Apparantly that function doesn't exist.. i swear i saw it earlier today, sigh

~Genx

Edited by Guest
Link to comment
Share on other sites

Myeh, but middle values works just aswell, i just don't look at the FM help as much as i should, it would often save me a lot of grief. To tell you the truth this orange is just putting me off and i've lost access to my other account because i changed a skin (or so i think) so i'm to scared to change this one lol.

Link to comment
Share on other sites

OK, here goes, just for the fun of it...

I needed 3 scripts to do this, plus 4 fields (or variables). It is just in FMP6, so FM8 syntax might be different. Method probably the same. Open to any other more simple actions though. This is not very fast, but it works.

FIELDS:

showValueListItems=

ValueListItems( Status( CurrentFileName); "New Value List" )

This can be any type of value list, just plain text, conditional or internal/external field list.

global field for singleValueListItem [text]

$$variableValue ( FMP6 global text)

$$variableCounter( FMP6 global num)

SCRIPT 1

To be assigned to a navigation button that goes to the layout that contains this value list features and resets all to 1 and empty:

Set Field ["variableCounter", "1"]

Set Field ["variableValue", "Left( showValueListItems; Position( showValueListItems; "¶" ;1;1)-1)"]

Set Field ["global_singleValueListItem", "Left( showValueListItems; Position( showValueListItems; "¶" ;1;1)-1)"]

Halt Script

SCRIPT 2= gotonext value

Loop

If ["variableValue = global_singleValueListItem"]

Set Field ["variableValue", "Middle( showValueListItems; Position( showValueListItems; "¶" ;1;variableCounter)+1; Position( showValueListItems; "¶" ;1;variableCounter+1) - Position( showValueListItems; "¶" ;1;variableCounter)-1)"

Set Field ["global_singleValueListItem", "Middle( showValueListItems; Position( showValueListItems; "¶" ;1;variableCounter)+1; Position( showValueListItems; "¶" ;1;variableCounter+1) - Position( showValueListItems; "¶" ;1;variableCounter)-1)"]

Set Field ["variableCounter", "variableCounter + 1"]

If ["not IsEmpty( global_singleValueListItem)"]

Halt Script

Else

Set Field ["global_singleValueListItem", "Right( showValueListItems; Length(showValueListItems) - Position( showValueListItems; "¶" ;1;variableCounter-1))"]

Set Field ["variableValue", "Right( showValueListItems; Length(showValueListItems) - Position( showValueListItems; "¶" ;1;variableCounter-1))"]

Set Field ["variableCounter", "variableCounter - 1"]

Halt Script

End if

End if

Exit Loop If ["variableValue <> global_singleValueListItem"]

End Loop

SCRIPT 3= gotoprevious

If ["variableCounter = 1"]

Halt script

End if

Loop

If ["variableValue = global_singleValueListItem"]

Set Field ["variableValue", "Middle( showValueListItems;

Position( showValueListItems; "¶"; 1; variableCounter -1) +1;

Position( showValueListItems; "¶"; 1; variableCounter ) - Position( showValueListItems; "¶"; 1; variableCounter -1) -1)"]

Set Field ["global_singleValueListItem", "Middle( showValueListItems;

Position( showValueListItems; "¶"; 1; variableCounter -1) +1;

Position( showValueListItems; "¶"; 1; variableCounter ) - Position( showValueListItems; "¶"; 1; variableCounter -1) -1)"]

Set Field ["variableCounter", "variableCounter -1"]

If ["not IsEmpty( global_singleValueListItem)"]

Halt script

Else

Set Field ["global_singleValueListItem", "Left( showValueListItems; Position( showValueListItems; "¶" ;1;1)-1)"]

Set Field ["variableValue", "Left( showValueListItems; Position( showValueListItems; "¶" ;1;1)-1)"]

Set Field ["variableCounter", "1"]

halt script

End if

End if

Exit Loop If ["variableValue <> global_singleValueListItem"]

End Loop

LOL, I had fun with this!

Link to comment
Share on other sites

Oh have pity with us poor folks of Filemaker Pro 6... Just got home and looked at your example in fp7. Deep sigh. What more can I say?!

Oh I just thought of something, how about doing a simple alternative in six then...? That will truly impress me!

Link to comment
Share on other sites

It shouldn't be too hard to adapt it to version 6. Obviously, without a script parameter, you'd need two separate up/down scripts. But other than that, it's just a matter of getting rid of Let() by replacing each variable with it's definition. I don't know which value functions are availble in 6, but you can always count carriage returns instead. Or, if the value list is known to contain only single-word values, you can use word functions.

Link to comment
Share on other sites

This topic is 5645 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.