DanBrill Posted January 28, 2004 Posted January 28, 2004 Hi, I have a field 'x' with 10 repetitions and a global field 'gx' also with 10 reps. i want to make the first rep of x equal to the first rep of gx, the second rep of x equal to the second rep of gx, and so on. Set Field ["x", "gx"] works fine for the first repetition. I thought that Set Field ["x"-2, "GetRepetition(gx,2)"] would do the trick to set the second repetition of x to the second repetition of gx. But it always returns an empty field. Both are set to Number, and there are no relationships involved -- i.e., both fields are local to the file. I've also tried it using an "Insert Calculated Result" step, but no luck. Any ideas? Thanks, Dan
-Queue- Posted January 28, 2004 Posted January 28, 2004 It's a bug with GetRepetition( ). For text fields you'll need GetRepetition( ) & "", for numbers, GetRepetition( ) + 0, for dates, GetRepetition( ) & TextToDate(""), and for time, GetRepetition( ) & TextToTime(""). There is no solution for containers aside from hardcoding, which really pisses me off.
DanBrill Posted January 28, 2004 Author Posted January 28, 2004 Hey thanks! It works. I knew it wasn't me. Another problem (though I don't know that it qualifies as a bug) is that you can't use GetField or Status(currentFieldName) with get repetition. I had a sweet idea that I wanted to implement last night, but nothin' doin'. Thanks again. Combined with your advice from yesterday, I've just about got a problem that has really been vexing me solved. I'll post an example when I'm done. Dan
Ugo DI LUCA Posted January 28, 2004 Posted January 28, 2004 You should have a trip to the sample forum and download Ernst's SetRepeating demo. Really. Plus I don't get why you can't use GetField with GetRepetition. I have plenty of those calcs in my files. GetField(GetRepetition(Constant::g_selectFieldOrder, 1& " ")) as you can use GetField("MyField_"&globalCounter)
Ugo DI LUCA Posted January 28, 2004 Posted January 28, 2004 ...and I'm quite sure you can use the Status(CurrentFieldName) too. Say your field could be Field_1 to Field_x then GetField(Left(Status(CurrentFieldName), Position(Status(CurrentFieldName),"_",1,Patterncount(Status(CurrentFieldName),"_"))&global) Wouldn't it work ?
DanBrill Posted January 28, 2004 Author Posted January 28, 2004 Hi Ugo, It was the other way around. I was trying: GetRepetition(GetField(x),2) and GetRepetition(Status(CurrentFieldName),2) to get the second repetition of field x, a calc = "Field"&i, which would increment by 1 with every step of a loop's iteration. My thought was that I'd get rep 2 of field Field1 on the first time through the loop, then rep 2 of Field2, and so on. But it won't take anything other than an actual field name as a parameter for GetRepetition. Dan
Ugo DI LUCA Posted January 29, 2004 Posted January 29, 2004 Hi Dan, I see... Yes you must specify a valid field name with the GetRepetition ( ). I can't think of any workaround to do the job, but true this could be an interresting feature to be added to 7.
Ugo DI LUCA Posted January 29, 2004 Posted January 29, 2004 Dan, May be you ended with this same solution. If not, here's a workaround involving a calculation that would use the Status(CurrentFieldName). As usual, I over complicated it , but a single Case could do the job too. Hardcoding it is the only way I can think to make it work. SetGetRep.fp5.zip
The Shadow Posted June 19, 2004 Posted June 19, 2004 DanBrill said: GetRepetition(GetField(x),2) This now works correctly in FM7.
bruceR Posted June 21, 2004 Posted June 21, 2004 1. When setting one rep from a "parallel" rep, you do not need to use getRep. FileMaker "knows" which rep you are referring to. You script should go like this: set field [MyRep [1], gRep] set field [MyRep [2], gRep] set field [MyRep [3], gRep] etc. 2. If you want to set a rep by rep number, it is better to use a lookup techique. This allows a single script action to programatically set any repeat without looping. Individual repeats ARE addressable but they need to have a complete unique address and this is the way it has always been done since 2.1. The first step is to recognize that each rep must have a unique ID. This is done by first creating a row number rep, auto-populating it with values 1 thru N where N is the number of repeats. Then you create a calc field, extend(RecordID) & "." & RowNum. For the moment I leave the other steps as an excercise for the reader.
Recommended Posts
This topic is 7463 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