Jump to content

Set field repetitions problem


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

Recommended Posts

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

Link to comment
Share on other sites

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. ooo.gif

Link to comment
Share on other sites

Hey thanks! It works. I knew it wasn't me. smile.gif

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

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

...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 ?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 4 months later...

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.

Link to comment
Share on other sites

This topic is 7241 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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