RWX Posted June 1, 2005 Posted June 1, 2005 Another question that I feel I should know the answer to...but can't seem to remember! I'd like to be able to clear all repetitions of a repeating field. I've created payment matrix grid using records (rows) with a repeating field (columns). I'd like to be able to click a button and clear all repeating field values. I can step through the records (rows) using a simple loop, but I can't seem to figure out how to clear every repetition of the repeating field. Thoughts? Thanks! -Rob
-Queue- Posted June 1, 2005 Posted June 1, 2005 You can either hard-code each repetition in a set of Set Field scripts, Set Field [repfield; ""] Set Field [repfield[2]; ""] Set Field [repfield[3]; ""] etc. or put repfield on a layout, formatted to display all repetitions and with a Tab order that travels sequentially through the repetitions. Put at at least one field after or before repfield, so that it is tabbed into after you tab out of the last repetition. Then Go to Layout [layout with repfield] Go to Field [repfield] Loop Set Field [ ; ""] <-- do not specify the field to be set Go to Next Field Exit Loop If [Get(ActiveFieldName) <> "repfield"] End Loop substituting your field name for repfield, of course.
Søren Dyhr Posted June 1, 2005 Posted June 1, 2005 I've created payment matrix grid using records (rows) with a repeating field (columns). You mean Choose(.....GetRepetition kind of stuff, doesn't make sence any more if it ever have?? Use multi conditioned relations as well as sliced up portals. Before 7.0 was Lookup Next Higher a safer bet speedwise!! --sd
Søren Dyhr Posted June 9, 2005 Posted June 9, 2005 Well in another thread came this reply ...only thing is that I came from relational databases to Filemaker, which apparently is the uncommon arrival to the tool as such: One of the biggest advantages of Filemaker is the comparatively gentle learning curve, and part of the reason for that is the existence of repeating fields. There is a reason most newbies overuse repeating fields: fully understanding the concepts behind relational databases takes time, and repeating fields allows them to still create useable databases while learning. I feel it's like giving brandy to an alcoholic - but I came to believe that a halfhearted attempts is better than nothing at all, from the new tune "Help Somebody" performed/written by the Van Zants Bros. (Skynard Lynard) ...so there isn't apparent no need to hessitate to throw this solution up ...where is the freeking Greamlin for snakeoil-salesman??? --sd repClearTest.zip
Raybaudi Posted July 20, 2005 Posted July 20, 2005 Hi, this is another way... Clear[select;repeatingField] Loop Go to Next Field Clear[select] Exit Loop If[Get(ActiveFieldContents)=Last(repeatingField)] End Loop Commit Records/Requests[No dialog]
-Queue- Posted July 20, 2005 Posted July 20, 2005 Better to use Set Field than Clear, so that the Clipboard contents are left intact. Also, if the value in the last filled repetition is the same as the value in one of the previous repetitions, the loop will exit before completion.
Søren Dyhr Posted July 21, 2005 Posted July 21, 2005 Yes it's just two lines (tounge in cheek) GTRR(SO) Replace This is a kindly hinting in direction of the existence of better structures sans repeating fields!!!!!!!!!!!! --sd
Lee Smith Posted July 21, 2005 Posted July 21, 2005 Hi JT, I have always looked at the Clear Step as a simple Delete. The FileMaker help would seem to confirm this: Deletes the contents of the specified field in the current record. Clear removes the contents of the field without placing the contents on the Clipboard. If you want to paste the field information, use the Cut script step. Use Undo immediately to restore the contents. Lee :cool:
Raybaudi Posted July 21, 2005 Posted July 21, 2005 (edited) if the value in the last filled repetition is the same as the value in one of the previous repetitions, the loop will exit before completion No. You have to try... Whatever are the repeatition values, the loop stop always on the last rep. ;) Edited July 21, 2005 by Guest
-Queue- Posted July 21, 2005 Posted July 21, 2005 Interesting, Lee. I was not aware of that. Daniele, I would think that is a bug or undocumented 'feature' which should not be relied upon in the future. Instead, a test using Get(ActiveRepetitionNumber) would probably be more reliable. It is very odd that Last appears to contain a pointer to the repetition number and not just its value though. :qwery:
Ender Posted July 21, 2005 Posted July 21, 2005 Hey Queue, when did you pass 5000? I suppose it was 17 posts ago, but did I miss the party, or did we forget to throw one? You're so prolific! Congrats! :yourock:
Lee Smith Posted July 21, 2005 Posted July 21, 2005 Hi JT, I was trying to Edit my post before anyone else responded, but I have been having trouble with the site today, and had to restart my computer to ensure it wasn't me. Unfortunately, it was in the middle of my post here. Sorry if this is "repeating" earlier information, or isn't germane to the subject at hand, but this is straight out of the Online Help. The following example clears the values in a repeating field with three repetitions. Clear [select, table::field(3)] Clear [select, table::field(2)] Clear [select, table::field] Lee
Raybaudi Posted July 21, 2005 Posted July 21, 2005 Hi, Queue I don't think that it is a bug... Loop Go to Next Field Clear[select] -- now the Active field contains "" and this value isn't sure the same of the last value Exit Loop If[Get(ActiveFieldContents)=Last(repeatingField) ] --but if the last is setted to "", than the loop stop End Loop BTW I think it is a nice feature for stopping a loop in a repeating field
comment Posted July 21, 2005 Posted July 21, 2005 It is very odd that Last appears to contain a pointer to the repetition number and not just its value It doesn't. That's not how Daniele's script work. Here's another version of the same thing, but perhaps making the principle at work a bit clearer: ... Loop Go to Next Field Clear[select] Exit Loop If [ IsEmpty ( Last ( repeatingField ) ] End Loop Oh, and congrats on your 5K from me too! :party:
Raybaudi Posted July 21, 2005 Posted July 21, 2005 Hi, Soren very nice your solution and the quickest ! ;)
-Queue- Posted July 21, 2005 Posted July 21, 2005 Lee, yes, I knew how Clear worked, but I did not know that it had no effect on the Clipboard. I wonder which is faster though, Clear or Set Field... Mike, thanks! I didn't quite make my goal of 5000 in 2 years, but at least I was only a couple of weeks off. If I hadn't stayed away for three months, I would have beat the goal. Oh well... Comment, it took me a while, then I slapped myself in the head. I kept thinking the GTNF was after the Clear, in which case it made no sense to me. I must be getting slow in my prolificity. :idunno:
Lee Smith Posted July 21, 2005 Posted July 21, 2005 Lee, yes, I knew how Clear worked... I knew that, and I wasn't trying to imply otherwise. I just thought it interesting how these steps had changed in version 7, when compared to v6. I don't know if I would have realized that you no longer need to use the "-" here, unless it beeps at you. I just don't use that many repeats. Clear [select, "Repeating Field"] Clear [select, "Repeating Field" -2] Clear [select, "Repeating Field" -3] However, this gives me an opportunity to increase my post count. Congratulations on your 5,xxx posts. I have learn a great deal because of your participation. Lee :cool"
-Queue- Posted July 21, 2005 Posted July 21, 2005 Very true. Also, GetRepetition( field, X ) now works as field[X], a long-overdue simplification, IMO. I have learned a lot from you as well. You are quickly approaching 3500. So I daresay we'll be having your 5000th postiversary in the not-too-distant future. And just because I can, :yay:
Recommended Posts
This topic is 7064 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