AnsweredAssumed Answered

Variables: How to assign variables to calculated field names

Question asked by ColinChandler on Jan 24, 2011
Latest reply on Jan 25, 2011 by ColinChandler


Variables: How to assign variables to calculated field names


Hi – I am a relative newb, so please forgive if this is a complex approach to a simple problem, in FM 11.0v2

I am attempting to set up a table that will receive downloaded data from a barcode scanner.

I have a table of 150 global fields to accept the incoming data. Table – “Barcode” which has global fields “Line”

So far so good.

Now I need a script to take each value from each field and convert it to a variable I can use in a variety of functions on 3 other tables. The names of the variables need to incrementally increase as well, of course.

This would give a list of unique variables that correspond to each field in the “barcode’ table.

My issues fall into 2 parts

1. Navigation to fields; I thought perhaps this aproach would work

Set Variable [$Num; Value:1] #Num is my line counter

Set Variable [$Name; Value:”Barcode::”&”Line”&$Num]

Now I need to get to the $Name field...Go to Field would be just lovely – ‘cept it doesn’t take variables as its direction...

I could instead use Go to field and then, Go to next field - just seems a bit fragile...

2. I need the value of the field the script has arrived at to be set as a variable - with a variable title

The logical approach seems to use Get (ActiveFieldContents)

Eg - Set Variable [“Line”&$Num; Get(ActiveFieldContents)

But of course that wont work as an identifier

*It works to manually Set Variable [$$Line1; Value:Barcode::Line1] , then line2, Line 3 etc – but with a possible 150 entries, this is very inelegant (as I found noted on various other threads!)

I am hoping that someone may be able to point out something bleedingly obvious as a change of approach? Or to point to a thread I have missed on the topic ...

Thanx in advance