Jump to content

Set Repetition based on another field value?


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

Recommended Posts

  • Newbies

I'm certain I'm just missing something but how do I set a specific repetition in field1 based on the value in field2? In other words if field2 contains 6 I want to set repetition#6 in field1 to value X.

I've browsed this board and searched docs/etc. but all I've found is the Set Field command which requires a hard-coded repetition #. I could make that work with a brute force sub-script but I'm certain there's a better way and I'm just being an idiot.

Thanx!

CharlieD

Link to comment
Share on other sites

I was wrestling with this the other day and concluded that that's what we're stuck with. I also couldn't find a way to set the repetition outside of hard coding it. Pitty, because a repeating field could make a darn fine array variable otherwise.

I'll be more than happy if someome can tell me I'm wrong. (Act fast -- I don't often make this offer. smile.gif )

Dan

Link to comment
Share on other sites

Does this also mean that if the value in field 2 contains 5, you would like to set repetition 5 equal to X?

The only way I have found to do this is to use the example plug-in that comes with Developer 7, also available for download at www.databasepros.com, to run a script on exit from field 2, which will set the correct value(s) for you.

If you'd like I can post a sample file.

Best regards,

Link to comment
Share on other sites

  • Newbies

Thanx for the file. I think I wasn't clear enough in my original posting so sorry to have bothered you. The "X" I was referring to was really an x...as in any random value not a literal X. : )

The core logic works and is the brute-force method I was trying to avoid implementing. I also agree with one of the earlier responders...if they ever implement a real SetRepetition function then repeating fields would be great general purpose arrays.

For now I'll make a brute-force script that encodes the rep # and value in the parameter and dupe it as needed.

Thanx.

CharlieD

Link to comment
Share on other sites

Michael Myett said:

Does this also mean that if the value in field 2 contains 5, you would like to set repetition 5 equal to X?

The only way I have found to do this is to use the example plug-in that comes with Developer 7, also available for download at www.databasepros.com, to run a script on exit from field 2, which will set the correct value(s) for you.

If you'd like I can post a sample file.

Best regards,

If I understand correctly what is being asked here, there is a much easier (with no plugins) way of doing it:

FMP7 has a new calculation: Get ( CalculationRepetitionNumber )

( rather than get(activeRepetitionNumber) -- useful in script))

What this will do is return the number of the repetition in a calculation.

You could use it in a calculation on a repeating field as such:

case(Get ( CalculationRepetitionNumber ) = extend(field 2),"X")

Edit: Note that this will work if the calculation is an actual calcuation (not an autoEnter Calcuation)

If you want the user to be able to edit the values in repetitions then what you need is three fields:

RawData: text field with 10 repeating values

RepNumber: Number field

ModifiedData: Calculation field of type text with 10 repetitions. Calculation: if(Get ( CalculationRepetitionNumber ) = extend(RepNumber); "Whatever"; GetRepetition(RawData;Get ( CalculationRepetitionNumber )))

If you want to give the appearance that the modified data an editable field (ie non-calculated field), you coul place the ModifiedData field on top of RawData with a opaque fill. Turn off "Allow field Entry" on the ModifiedData field. Now when you click on the repetition it go to the field belowit (field RawData)

Link to comment
Share on other sites

I thought of another way to do this via scripts, which is the setting I originally needed it it. I'm surprised I didn't think of this sooner -- it is very low-tech. If you issues a 'Go To Next Field' command and you are in a repeating field you actually go to the next repetition of that field. So just by looping and counting you can set up an array as you like.

The downside is that you have to have the field visible on the layout in order for this to work, so you can either set up a developers layout, or create an 'invisible' field on a real layout.

See attached.

Dan

test rep set.zip

Link to comment
Share on other sites

This topic is 7227 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.