Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

  • Below is an image of my Script.
  • Problem Area:(Highlighted in Yellow) Set Field [Table::Vehicle_Description1; $&"VD&$i
  • Goal: Variables $VD1-$VD8 are holding data.  I am doing a loop $i which is a counter that increments from 1 to 8.  If there is Data within the variable then I want the field Vehicle_Description1 to be filled with $VD1 on the 1st iteration.

     

  • Current Output:  When running the script, assuming data is in $VD1, I am getting VD1 within Vehicle_Description1 instead of what data is within the variable $VD1.

     

  • What is unusual:  The counter $i is working fine.  You can see this with the output VD1

     

  • InShort: How do you read a variable when you have to concatenate and read a dynamic variable?

     

  • Any help or suggestion would be much appreciated. :laugh2::worship: 

     

fm_pro3.jpg

Posted

Set Field [ table::Vehicle_description1; Evaluate( "$VD" & $i )]

  • Like 1
Posted

 ricardor  BruceR--> Thank you, thank you. :worship:  :worship: 

I did not know about Evaluate() but I figure that had to be a way.  

I also would have never known about repetitive variables.  It sound as if I do not need to use a counter if I am using a repetitive variable.  Wow, that is cool.

Learned two new things today.

Thank you both again for the valuable feedback, much appreciated. :party: 

Posted

Yes, I agree that repeating variables are the better approach.

Posted

Or use repetitive variable $VD[1], $VD[2] etc....  by loop  $VD[$i]

This is going to sound stupid, :grad:  but how might I do this.

 

Objective: I want to initialize 8 variables VD1 thru VD8 to "". 

Error: Set Variable[$VD[$i]; Value:""]

Logic: Might not be correct either

Goal: Use repetitive variable within looping to simply and compress code

 

Below is the code I have come up with thus far:

Set Variable[$i: Value:1

Loop

Set Variable[$VD[$i]; Value:""]

Set Variable [$i; Value:$i+1]

Exit Loop If[$i >=8]

End Loop

 

:hmm:

Posted

That's a pretty reasonable approach to set a repeating variable. I would make a couple nitpicky minor changes, but the script is sound.

 

Keep in mind that unlike a lot of programming languages, FileMaker does not "initialize" variables. To FMP, an empty variable is a non-existant variable. Some FMI engineers may strike me down, but there is no difference between "empty" and "null" variables.

Posted

FWIW I generally prefer putting the exit condition at the top of the loop.

 

That way you know nothing ever gets processed if it does not satisfy the exit condition.

In this case the process is very simple but in more complicated scripts it makes it easier to assure yourself that it is OK to take this action (change data, delete a record, whatever)

Sort of like saying, only touch this data if...

 

 

Set Variable[$i: Value:1

Loop

Exit Loop If[$i >8]

Set Variable[$VD[$i]; Value:""]

Set Variable [$i; Value:$i+1]

End Loop

This topic is 4342 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
×
×
  • Create New...

Important Information

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