Jump to content
Server Maintenance This Week. ×

Set Fields by Indirection!


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

Recommended Posts

One of my most favorite tidbits of knowledge that I gained while at Devcon (thanks to Andy Le Cates) was a very elegant method of setting fields by indirection.

As you know the Set Field command requires you to manually choose a field in order to set it. But sometimes you may have a layer of abstraction or have a large number of fields to set based upon data contained in your records. Thus your script will be rather lengthy because you need to target each respected field.

Well with a new feature of FMP 8.5 script step Goto Object and use of Layout Object names you can effectively set a ton of fields via indirection...


Go to Layout [ “DEV - art” (art) ] 

Show All Records 

Go to Record/Request/Page 

[ First ] 

Loop 

Go to Object [ Object Name: art::name; Repetition: art::rep ] 

Set Field [ art::graphic ] 

Go to Record/Request/Page 

[ Next; Exit after last ] 

End Loop 

Go to Layout [ original layout ] 

[float:right]

[/float]In this example i need to set a bunch of fields to the value of the records in the table.

By NOT specifying a target field with the Set Field command and placing the Go to Object just before the possibility unfolds allow my script to be simple and understandable.

Each field on the layout was given a name using the Object info pallet, corresponding to the a record in the art::name field. Some fields on my layout have repetitions and the second repetition parameter of Go to Object allows me to target that repetition.

Link to comment
Share on other sites

Nifty! Maybe this will placate some of those poor souls who've been begging for a dynamic Set Field[] for so long.

But I wonder...is LaCates going to hunt you down for sharing his intimate secrets with the rest of us? :) Maybe you can send him a poster!

Link to comment
Share on other sites

:)

I am sure he can recite each function and its definition and a dozen examples upside down & blindfolded in no less than 90 seconds.

- one caveat to this is if you run your DDR thru Inspector it feels Set Field with out a field specified is an error, and it will report as such.

Link to comment
Share on other sites

Yes, it is not all the much different from a properly done loop. However, if you cannot be sure of the order of the data coming in; ie., your loop in pre-8.5 would have to start over at the 1st field for each Set Field. Going directly to the object is much faster. Only 1 split-second instead of 10 :)-]

Link to comment
Share on other sites

  • 2 weeks later...

Hi Stephen,

thanks for the feedback...

--- [color:red]Retract request ...see below (I must remember to think before i speak/post :)

[color:#cccccc]Do you think its worth starting an Objects or Objects, Parameters & Variables Forum as i think they are pretty major for developers and would love to be able to have a focused response on these kind of questions when they arise and i dont quite have a place to put them at the moment.

---

These things really really excite me (don't meant to sound odd, but they are changing the way i work fundamentally).

Maybe I'm alone on this one and you may not feel their major enough, so just a thought. :(

best

Stuart

Edited by Guest
Link to comment
Share on other sites

Actually on reflection turning objects into a forum would not quite work as they are so dynamic and refer to pretty much all of the other forums anyway. Having an Objects forum would probably be more confusing in terms of posting than a help.

Having a forum for a script step or function is extreme... it would just be nice to stimulate more discussion and focus people on opening up the possibilities ...

Which i suppose is what you are doing with this post so thank you for that.

best

Stuart

Link to comment
Share on other sites

Stuart, thanks for the feedback. I did get your request but that got me thinking about the forums and exactly where to put it as it affects so many areas. I ended up reorganizing some forums in hopes that people will choose a forum to better target their issue. Right now there are so many posts that have little to do with the forum they are in. - Our moderators are doing what they can to move them to where they should be filed.

Link to comment
Share on other sites

Many thanks for your reply,

Its good to see Define Fields back on the top level.

Although also a bit off topic, I have posted a file that takes advantage of 8.5 and its new features ... my hope is that it could be a good open source project with small contributions ... and hope that yourself and John Mark may take a moment to look at it.

http://fmforums.com/forum/showtopic.php?tid/180252/

Best

Stuart

Link to comment
Share on other sites

  • 1 month later...

Hi, nice!

Just a helpful tip for people debugging when they have problems with go to object for dynamic field-setting...

Go to object[ objectNameOfField ] doesn't work if the field you wish to go to has a button attached to it!

In that case the button is selected with a thick border instead of the field being selected...

...that caught me out for a while.

Have fun everybody!

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

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