GetFieldName returns the name of a field.
GetFieldName ( QuestionSheet::ScreenAnswer )
return the same identical results here
GetFieldName ( "QuestionSheet::ScreenAnswer" )--don't think that will work and it's unecessary. Neither should you use Trim all in an attempt to remove spaces as any spaces in the field or table occurrence names are needed.
I suggest this line for your first script:
Set Variable [$$CurrentFieldName ; getFieldName ( QuestionSheet::ScreenAnswer ) ]
Then, to access the data in this field use: GetField ($$CurrentFieldName ) to "read" the data and Set Field By Name [ $$CurrentFieldName ; //put calculation here] to modify it.
The reason you'd use getFIeldName ( QuestionSheet::ScreenAnswer ) instead of just "QuestionSheet::ScreenAnswer" is that GetFieldName will automatically return the correct combination of table occurrence and field names should you change either of these two names where using text in quotes requires you to find and update that script step or script parameter expression.
Oh yes, instead of assigning the value like this in a script--which puts you back to one script for each field, I'd pass the field name as a script parameter with the getFieldName expression so that a single script:
Set Variable [$$CurentFieldName ; Value: get ( ScriptParameter ) ]
will server for all such fields.
At the end of your reply you suggest setting the variable what do you mean by (script parameter)?
Sorry to be dense.
When you use a script trigger, a button or the perform script step to perform a script, you can specify a script parameteter. Put the getFieldname expression inside the optional script parameter box.
Then the get ( ScriptParameter ) function can be used to retreive the value passed to the script as the script parameter. This is a very useful way to set up diferent buttons that pass different data to the same script.
Thanks I've nearly got it working now.
I didn't appreciate that Getfield gathered the data in that particuler field.
Also the need for the set field by name.
It's not very clear in the help files.