You can use a Custom Function to great Variables, but you a referring to have a lot of Variable and that is not recommended. Very hard to keep track of all Variables. Of what reason do you need so many Variables?
Any suggestion on what that custom function would be? I've tried Let and Evaluate but not found the key. Use the filed and add the custom function.
If it works, give yourself a raise and an extra week vacation..
Your offer is obviously of no value.
Why do you think you need to do this?
It was a joke...
I will be creating an unknown number of variables to be used in buttons, etc. and these will have values that change. I could and have hard code the hundred or so variables and run that script but I want to set the values using the two fields in loop running thorugh the hundred or so records.
I have done this quite easily in other db applications since I can write a one line function similar to
Set variable name in field A to value in field B.
I learned how to do this within 2 days of learning my first db, DBase in windows in 1984.
I have tried many ideas with FIleMaker but no luck. Stuck with that Set Var thing instead which means hundreds of lines of set variable.
I would suggest that, instead of using "hundreds" of separate variables, that you instead use either an array of values ( $$varName[x] ) or use a return-delimited list and extract the specific value needed via GetValue ( ).
But again, it begs the question Bruce asked: For what purpose? "Hundreds" of buttons would result in an unworkable user interface, so what are these hundreds of variables being used for? There's probably another way to accomplish this goal.
[...] or maybe Java(?) [...].
A new classic from the master.
It may be simple, make Let() formula and Evaluate() it,
Evaluate ( "Let($$" & table::varname & ";" & table::value & ")" )
if value is text you need Quote(table::value)
Amplifying Mike's point here, but also adding that in Java or other real programming languages, you NEVER create that many variables in a class or other object. NEVER. NEVER. NEVER.
If you were to run a Java source code analyzer like PMD or FindBugs on such Java code (free, of course), they would tell you to reduce complexity! Also, such source code with that many variables would never survive a peer code review!
Having so many variables "screams"...redesign.
HOPE THIS HELPS.
Just loop with the Let function which allows you to set variables dynamically as was mentioned earlier. We use this technique to allow for localization (multiple languages) in our solutions. For example, our "Kosmas" solution loads around 5000 phrases, all stored as global variables. All labels, headers, descriptions, tooltips...everything we possibly can is named with a global variable. Switching from English to Russian and then to Korean is easy. This even allows users to adjust the name of anything, solution wide, without having layout access.
Amplifying Mike's point here, but also adding that in Java or other real programming languages, you NEVER create that many variables in a class or other object. NEVER. NEVER. NEVER..
Just that a "variable" in Java is not the same as a variable in FM.
While a table with 300 fields is usually* a red flag, creating 300 variables ad hoc might be just the solution to a pressing problem, or be used for interface purposes.
So one should never say never (especially not in Caps Lock )
*Unless you need to manage an entity that *does* have 300 attributes.
A variable is a variable, sorry.
I can't think of a single entity that would need 300 variables, can you? Or, to wit, an entity that couldn't then be conceptually simplified.
The concept of "Abstraction" seems to be lost here.
Thanks for your reply.
I've considered many ideas including the repeating variable.
The idea is to create labels for buttons since the $$global can be used to name a button and for labeling fields.
I am using this for instant language changes. I only submitted the two fields but there would be a field for language name. Search for the language then loop through the records and all my buttonds and field labels would change to the user's choice of language.
I've done it by manually naming the variable and using a list and here's a sample line:
set var $loop to $loop +1
set var $$Done to getvalue $$list line $loop
Now add that line manually every time you need a new variable and it gets to be a burden. Hence my request.
I name my Done button $$Done and can change it with a language selection.