Newbies eldon Posted February 5, 2007 Newbies Posted February 5, 2007 Hi all, I am a complete and utter newbie to filemaker but have extensive experience of other dbms's (SQL Server, Oracle etc.) I am trying to do something very simple in a script but have no idea of the Filemaker syntax. Basically I have added a serial number column to a table that has existing records in it. All I want to do now is retreive all records and loop through incrememnting the value in that field by one so that I have a sequential number in there. I have looked at examples of looping through records on the web and they all start with Go To Layout Steps. What are layouts? Are these the equivalents of tables? How do I do the equivalent of SELECT * FROM myTable and then process those results? Any help really would be appreciated as I am floundering. Cheers, Eldon Ferran de Pol
Søren Dyhr Posted February 5, 2007 Posted February 5, 2007 with Go To Layout Steps. What are layouts? Are these the equivalents of tables? No they're are presentations of one single table occurence, you never work on a real table only on TO's ...because the pointer to a specific record demands it. If your search or querry produces a found set should it always be show in a layout, to get the record pointer pointing at one specific record, a very important prerequisite for any scripted workings thru the found set. A layout doesn't nessersarily need to have any fields show, you can reach the field directly and indirectly over a relational dependency anyway via the Set Field[ command. But more practically minded would probaly hate this abstraction an begin to apply fields to the layout, to substantiate the metaphor. When that is done can some of the looping be hidden away to be performed behind the screens by the engine instead of dedicated scripting: http://www.filemaker.com/help/Script-Steps52.html The command is however not quite embraced by developers, because in a multiuser environment will each execution of this tamper with what other users are looking at a overlapping subset of records. Not that the value changes in front of their eyes, but the info gets unreliable, if a user puts his cursor in a modified field. --sd
Newbies eldon Posted February 5, 2007 Author Newbies Posted February 5, 2007 Thanks for your answer. Given the link to Replace Field Contents which looks very useful how do I get that set of records I want to apply it to. I have found so many examples that talk about loop through find results but how do I get them in the first place. I have a a table called myTable. How do I open all records from that table in a script and then loop through it?
Inky Phil Posted February 5, 2007 Posted February 5, 2007 (edited) Eldon The link that soren pointed you to showed how you can serialize a set of records without the use of a script. I point that out just in case you missed it. If however you really want to script it would be along these lines Go to layout(any layoutthat is setup to show records from myTable) Show all records Set Variable [$counter; 1] Go to record(first) Loop setfield[your serialfield;counter] Set Variable [$counter;$counter+1] go to record (next;exit after last) end loop Thats about it really, the variable being preceded by one '$' prefix means that the variable only survives for the duration of the script. A $$ prefix would mean it would exist outside of the script Don't know if that helps but it answers your last question Phil Edited February 5, 2007 by Guest added show all records step
Newbies eldon Posted February 5, 2007 Author Newbies Posted February 5, 2007 thanks alot I shall have a play. I did realise that that was a solution that didn't require but had something of a terminology problem with some of what was said. I am fine with the script approach as this is a one off hiot which my serial number field should resolve from there on in.
Recommended Posts
This topic is 6503 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 accountSign in
Already have an account? Sign in here.
Sign In Now