Jump to content
Server Maintenance This Week. ×

Using a script variable in a Perform Find


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

Recommended Posts

This one has me stumped. I'm trying to create a script that finds a particular record, and for various reasons I'm trying not to use GTRR.

I'm setting a script variable:

Set Variable [$y; Value:px_CREL_patientID.fk]

(at this point, if I set a field to be $y, it comes out as it should - 1089, or some similar number). Then:

Go to Layout [Contact_Rship]

Then I show all records and unsort all, because I'm wanting to do the find on the whole range of records. A pause step confirms for me that I have the whole range of them. Then:

Perform Find [Restore]

Where the find command is:

ContactRShip::PatientID.fk = $y

What comes up then is an error message, saying "No Records Match This Set of Find Requests". I was expecting to get a found set of records with the PatientID.fk of 1089 (or whatever).

But if I press cancel and then enter Find Mode and enter 1089, or whatever other value $y was, I get the appropriate found set.

So it looks like it's not recognising that $y is a script variable, and is searching for "$y" instead.

I know there's an easier way, using GTRR, but this is partly about me learning how to use the Perform Find properly, and it's just not coming out the way that it looks like it should. I must have some misunderstanding of either the way the Perform Find works or how script variables work. Help!

  • Like 1
Link to comment
Share on other sites

Perform Find [ Restore ] can only be used for literal text. Instead use:

Enter Find Mode [ ] ... uncheck Pause

Set Field [ ContactRShip::PatientID.fk ; $y ]

Perform Find [ ]

And, by the way, there is no need to find all records before performing a find ... a find searches all records. Neither is an unsort necessary first; for similar reasons.

LaRetta :wink2:

  • Like 2
Link to comment
Share on other sites

Oh, I knew it had to be something basic!

Thanks for that, it works like a charm now. :

Funny, I've got heaps of FMP books, but I don't think any of them mention that script variables don't work in a find command. Funny sort of limitation - I would have thought anything you can do in a 'step-wise' find (as you've just shown me) would be able to be handled by the Perform Find step.

Well - you live and learn!

Thanks so much. :)

Link to comment
Share on other sites

Perform Find [ Restore ] can only be used for literal text.

Well I wasn't actually correct in my wording ... Find Requests (whether in Enter Find Mode[], Perform Find[], Constrain Found Set or Extend Found Set can only hold literal text (and not variables, globals or calculations). I hope I'm corrected if my wording still isn't quite right.

Link to comment
Share on other sites

  • 4 weeks later...

Hi Tim,

If you want to perform an AND search (meaning both criteria must exist in the resulting records), you would just add a second Set Field[] with the additional variable, such as:

Set Field [ text1 ; $var1 ]

Set Field [ text2 ; $var2 ]

If you want to perform an OR search (meaning one or the other two variables must exist) then you would insert a New Record/Request between them (be sure you are still in Find Mode at the time or it will create a new record instead of a new request), such as:

Set Field [ text1 ; $var1 ]

New Record/Request

Set Field [ text1 ; $var2 ]

LaRetta :wink2:

  • Like 1
Link to comment
Share on other sites

  • 3 months later...
  • 2 years later...

Well I wasn't actually correct in my wording ... Find Requests (whether in Enter Find Mode[], Perform Find[], Constrain Found Set or Extend Found Set can only hold literal text (and not variables, globals or calculations). I hope I'm corrected if my wording still isn't quite right.

Loretta,

Are you saying that if I set a $var equal to a field and then PERFORM FIND on $var, it will not work?

I have been using that technique on several modules and works great. Or, do I misunderstand you?

ishot-25.jpg

Except for this: http://fmforums.com/forum/topic/78794-strange-find-result/page__p__367966__fromsearch__1#entry367966

in which case I need a way to 'recommit' the database to reflect a changed field. Got any ideas?

Thanks

ron

Link to comment
Share on other sites

Loretta,

Are you saying that if I set a $var equal to a field and then PERFORM FIND on $var, it will not work?

I have been using that technique on several modules and works great. Or, do I misunderstand you?

In 2008 using a $variable did not work. This is a new feature in FileMaker 11.

Link to comment
Share on other sites

This topic is 4705 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
×
×
  • Create New...

Important Information

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