January 27, 200421 yr Is it possible to use a Set Field script step where the name of the field you are setting is a variable? Using the GetField command I can specify the outcome as a variable field name. Can it be done on the left hand side of the equation? For example: Set Field ["i" "1"] Loop Set Field ["ResultField1" "GetField(gVarFieldName)"] Set Field ["gVarFieldName" ""OutcomeField" & i"] Set Field ["i" "i+1"] End Loop First iteration ResultField1 is set to OutcomeField1. Next time through to OutcomeField2, etc. Is there any way to increment the field being set, so that the first time ResultField1 would be set, then ResultField2, etc. In a similar vein, is there any way to set the repetition of a field that is being set with a variable. It seems like so many of these things could be done with incrementing loops, but it sure feels like I'm doing a lot of manual mouse clicks. Thanks for any help, Dan
January 27, 200421 yr Unfortunately, Dan, I believe the answer is no on both counts. The way I usually get around this is to have a layout with the fields in the order you will set them. Then you can use Go to Next Field, as long as the tab order is set correctly, to loop through the fields without hard-coding each one. This is very handy for setting repetitions, as well. You can use a global counter that either stores the number of repetitions, number of fields, or the field name at which to stop, and Exit Loop accordingly.
January 27, 200421 yr It sure would be nice to be able to specify the field programatically, though. Maybe someday...
January 27, 200421 yr I should also add that when using Set Field, you'll want to leave it unspecified and only enter the calculation. That combined with Go to Next Field is what does the trick.
January 28, 200421 yr Hi Dan, Apart the loop process on a specific layout with a tab order, as Queue suggested, you can also have your Result simply set this way. Say Outcome_1, Outcome_2, Outcome_3,... SetField[g_counter,0] SetField[g_variableFieldName, "Outcome_"] GoToLayout[TheOnWithResultsInOrder] GoToField[first] Loop EndLoopIf[g_counter = x iterations] SetField[g_counter,g_counter+1] SetField[,GetField(g_variableFieldName&g_counter)] GoToNextField EndLoop Just in case
January 28, 200421 yr Of course it's easy with applescript. setField(targetField, sourceField) on setField(x,y) get data cell y of current record copy result to y get data cell x of current record copy result to x copy y to cell x of current record end setField Regarding repeating fields, they can be individually addressed by using lookups.
Create an account or sign in to comment