Micah DJ Posted May 12, 2004 Posted May 12, 2004 Hi there, Edit: The basic question is: In FMP7, Can I create a loop that will go through and process on fields in the same table with names that are identical except for a succeeding number? (For example the fields are : Value1, Value2, Value3, etc) -------- Lots more details follow in case the above isn't clear as to what I'm trying to do. I'm hoping this is easy enough to do. FMP 7 - Basically, I have a selection of related records listed in a portal. I'm trying to create a script to copy the values from a single field in those related records to individual fields. I know I can make it work like this: ---- Set Field[Table1::Count;1] If [Table1::Count <= Table1::RecordTotal] Go to Portal Row [select; No dialog; Table1::Count] Copy [select;Table2::PortaledField] Paste [select;Table1::Copiedfield1] Else Insert Text[select; Table1::Copiedfield1; "No related data"] End If ---- But there's over 100 iterations and it seems to me that this is screaming to be looped. My problem is, I can't figure out how to reference a field name as anything but an absoulute reference to tablename::fieldname in a script. I'm hoping that I can somehow pass 'Textstring'+Count as a field name? Something like ---- Set Field[Table1::Count;1] Loop If [Table1::Count <= Table1::RecordTotal] Go to Portal Row [select; No dialog; Table1::Count] Copy [select;Table2::PortaledField] Paste [select;Table1::GetAsText("Copiedfield"+Table1:Count)] Else Insert Text[select; Table1::GetAsText("Copiedfield"+Table1:Count); "No related data"] End If Exit Loop If [Table1::Count>150] End Loop ---- Okay I realize I'm severely butchering the syntax.. but the basic question is this: Can I create a loop that will go through and process on fields in the same table with names that are identical except for a succeeding number? (For example the fields are : Value1, Value2, Value3, etc)
Vaughan Posted May 12, 2004 Posted May 12, 2004 Put the fields on a layout, then use the Go to Field [next, exit after last] script step to move through them. OTOH, lots of fields with a similar purpose usually means a relational design is required.
-Queue- Posted May 12, 2004 Posted May 12, 2004 In the vein of Vaughan's comment, I would use GetField( ) to set the current field with a related value. Something like Commit Records/Requests [No dialog] Loop Go to Next Field Set Field [ , GetField( "relationship" & Get(ActiveFieldName) )] Exit Loop If [Get(ActiveFieldName) = "{last field in the layout's tab order}" End Loop Don't specify the field to set, only the calculation to set it. If you need an iteration number, set a global number to 1 before the Loop portion, increment it after the Set Field (i.e. Set Field [gnum, gnum + 1]), and add it to the GetField( ) function.
Micah DJ Posted May 13, 2004 Author Posted May 13, 2004 Thank you both, I think I've got a handle on it now, I'm off to see if I can implement it! Micah
Recommended Posts
This topic is 7502 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