Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Setting Variable by Variable Name

Featured Replies

Hello,

I know there's an easy way to do this but right now I'm drawing a blank.

I am calling a script in Filemaker with the following script parameters:

List (

"$fileList=" & Quote ( $$COMBINEPDF ) ;

"$fileListName=" & Quote ( "$$COMBINEPDF" ) ;

)

I want to be able to reset the value of the script name contained within $fileListName to a null value once the script is completed.

I want to be able to reset the value of the script name contained within $fileListName to a null value once the script is completed.

I don't see how this related to what you said before this point, but if you want to clear the value of a variable in a script, use the set variable script step, and set it's value to "" (double quotes, ie empty string)

Set Variable( $$COMBINEPDF ; "" )

Note also that variables prefixed with a single $ expire automatically when the script runs out.

It is my understanding that the $variable value is always returned to a null value after the script been ran. FMP Help

  • Author

Erm, perhaps I did a poor job explaining what I'm trying to do here...The script parameter $fileListName is based upon a global variable name passed via ScriptParameter. I want to be able to reset the value of the global variable that has been passed into the script parameter once the script has successfully completed.

In this specific instance, I've used $$COMBINEPDF as an example of a global variable, but that variable could have just as easily been $$JOHN or $$HOWDOIWORK. Obviously I cannot call the Set Variable [ ] script step and and set the variable name, thusly:


Set Variable ;

Variable Name ; Evaluate ( "$fileListName" ) ; <-- Cannot do in Filemaker

Set Calculated Result ; "" ; <-- Easy peazy lemoneazy

)

Hopefully that explains it a little better...

Erm, perhaps I did a poor job explaining what I'm trying to do here...The script parameter $fileListName is based upon a global variable name.

I am afraid that's still the case, because the above makes no sense, at least not to me.

  • Author

I am afraid that's still the case, because the above makes no sense, at least not to me.

The script is being called with the script parameters:




List (

"$fileList=" & Quote ( $$COMBINEPDF ) ; <---$fileList then becomes a return delimited list

"$fileListName=" & Quote ( "$$COMBINEPDF" ) ; <----$fileListName then contains the string $$COMBINEPDF

)



The parameters are passed into the called script as local variable and then contain:



$fileList = "file1.pdf file2.pdf file3.pdf"

$fileListName = "$$COMBINEPDF"



If the script has completed successfully, at the end of the script I want to be able to reset the global variable contained within the local $fileListName variable.

I know this is possible as The Support Group has an article on their website http://www.supportgr...ing-a-variable/ containing a method to dynamically name variables based upon a loop and Evaluate. For some reason though I cannot get the method to work for a Global variable passed inside of a local variable as a literal name.

There is no Set Variable By Name[] script step. Still, if you have a $varName containing the $$variable name as a string, you could reset the $$variable by something like =


Let ( [

template = "Let ( $$variable = "" ; "" )" ;

formula = Substitute ( template ; "$$variable" ; $varName )

] ;

Evaluate ( formula )

)

There probably is a much simpler way to accomplish whatever this is supposed to accomplish.

There probably is a much simpler way to accomplish whatever this is supposed to accomplish.

That's what I was thinking!

Maybe using a script result (set by the Exit Script step), which the calling script can evaluate with Get( ScriptResult ).

There probably is a much simpler way to accomplish whatever this is supposed to accomplish.

Yes.

I don't think you're understanding the *scope* of variables. Why do this with all the quoting in the script parameter?

Put just "COMBINEDLIST" as your parameter.

In your script add:

Set Variable [ $fileListName ; "$$" &amp; Get ( ScriptParameter ) ]

Set Variable [ $fileList ; Evaluate ( $fileListName ) ]

Re-reading you post, I see you actually were pretty close...but you quoted the variable name in your Evaluate(). If you feed it without the quotes, it will work.

Edited by David Jondreau

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.