mlpremoli Posted November 26, 2014 Posted November 26, 2014 Hi All, first of all, forgive my English, as this is not my native language and I'm not bilingual. Glad to be here....seems to me that I've come the right place to learn about Filemaker. I need some help naming variables dynamically to move forward on my development: - I have a found set that can vary according to what I've searched - I need to go record by record in this found set and assign a value to a variable. One value per record, therefore one variable per record. - After that, I need to manipulate those variable in another process. The amount of records found have an impact on how many variables the process would define. So, if I find 10 records, I need to define Var1, Var2....Var10. Now if the process finds 20 records, I need to define Var1, Var2, Var20. Now, I don't want to define a fixed number of variables (ie 1000 variables) assuming that the process will never retrieve this number of records Long story short, I cannot manipulate the variable name to create it dynamically Have I explained myself I should I take more English classes? Is there a way to achieve this? Can anyone help pls? Help in advance. Regards. Mariano
comment Posted November 26, 2014 Posted November 26, 2014 I need to go record by record in this found set and assign a value to a variable. One value per record, therefore one variable per record. You cannot name a variable programmatically (at least not easily). However, you can easily assign a variable to each record by using the repetition number part of the variable's name, for example: Set Variable [ $myVar[Get(RecordNumber)] ; MyTable::MyField ] You can then use the expression $myVar[15] to refer to the variable holding the value of the 15th record of the current found set. Another possibility to consider is using a single variable to hold a return-separated list of values. 1
mlpremoli Posted November 26, 2014 Author Posted November 26, 2014 Thanks I can achieve the same with your last paragraph!thanks again
Kris M Posted November 26, 2014 Posted November 26, 2014 heres what i have used to set dynamic globals variable names Let ( [ vName = "TheName" ; vRep = 1 ; vValue = TheValue ; formula = "Let ( $$" & vName & "[" & vRep & "] = " & Quote ( vValue ) & ";"" )" ] ; Evaluate ( formula ) ) from here>>> http://fmforums.com/forum/topic/65364-dynamic-variable-name-is-it-possible/
mlpremoli Posted November 26, 2014 Author Posted November 26, 2014 Thanks Kris, I will try that function as well...seems a little bit difficult but I guess I'll make it work. My understanding is when I loop the VRep value should change so that the variable name changes as well, right? Could you pls, put a real example to understand this function deeply? Regards.
bruceR Posted November 26, 2014 Posted November 26, 2014 Script variables and global variables are really useful; but why do you think you need to do any of this? Global variables present a maintenance problem, because they persist until you clear them or until you close the file. Let's say you have declared the variables successfully; then what? How will you use them and how will you successfully refer to the correct one?
bruceR Posted November 27, 2014 Posted November 27, 2014 Here's an example using repeating variables. VarExample.fmp12.zip 1
LaRetta Posted November 27, 2014 Posted November 27, 2014 I like this, Bruce! But this is just for sake of demo, correct? It would not work in multi-user scenario and you'd instead use virtual technique for it, right?
mlpremoli Posted November 27, 2014 Author Posted November 27, 2014 Hi Bruce I see many ways in using the variables if I declare them with a certain logic in this way In my case all those variables I need them to declare in one layout / table and then take them to another layout and perform certain "finds" in another layout / table. Is far more easier to do this creating all these variables in one place, assign a value and then go to the other layout and use those values to perform my "finds" "extends" ,etc. Here's an example using repeating variables. Thank for this Bruce....I'll take a look tonight. Regards
Recommended Posts
This topic is 3649 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 accountSign in
Already have an account? Sign in here.
Sign In Now