Jump to content

Set Field where field name is variable


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

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This topic is 6572 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
 Share

×
×
  • Create New...

Important Information

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