Ocean West Posted August 28, 2006 Posted August 28, 2006 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.
Ender Posted August 29, 2006 Posted August 29, 2006 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!
Ocean West Posted August 29, 2006 Author Posted August 29, 2006 :) 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.
comment Posted August 29, 2006 Posted August 29, 2006 It also requires the field to be on a layout, and the script to be on that layout. All things considered, it's not that much different from looping thru the fields on a layout.
Fenton Posted August 29, 2006 Posted August 29, 2006 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 -]
Brudderman Posted August 30, 2006 Posted August 30, 2006 You don't happen to have a small demo file of this do you? That would most helpful to one (me) who is not so skilled. Thanks!! James www.james-mc.com
Fenton Posted August 30, 2006 Posted August 30, 2006 Here is a small file that parses web-submitted forms. It uses Go To Object on the Form layout. ParseEmailLoop8_5.zip
John Mark Osborne Posted September 8, 2006 Posted September 8, 2006 I like the parsing web forms example since I use it in a class I teach. I've tried to make it as adaptive as possible over the years. I'd be interested in seeing other examples of what people are doing with loops and Go to Object or just Layout Object Naming in general.
Brudderman Posted September 8, 2006 Posted September 8, 2006 Yes, I'd like to see those same examples myself.
Stuart Taylor Posted September 9, 2006 Posted September 9, 2006 Here are a couple of of object based examples ive been playing with ... my favourite is the calculation based on the merge field best Stuart DynamicTickbox.fp7.zip
Stuart Taylor Posted September 9, 2006 Posted September 9, 2006 (edited) 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 September 9, 2006 by Guest
Stuart Taylor Posted September 9, 2006 Posted September 9, 2006 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
Ocean West Posted September 10, 2006 Author Posted September 10, 2006 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.
Stuart Taylor Posted September 11, 2006 Posted September 11, 2006 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
Stuart Taylor Posted September 14, 2006 Posted September 14, 2006 Hi John Mark, Here is a little object trick just for you Portal Visibility http://fmforums.com/forum/showtopic.php?tid/180353/ best Stuart
Russell Watson Posted November 1, 2006 Posted November 1, 2006 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!
Recommended Posts