James Gill Posted September 11, 2012 Posted September 11, 2012 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.
dansmith65 Posted September 11, 2012 Posted September 11, 2012 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)
comment Posted September 11, 2012 Posted September 11, 2012 Note also that variables prefixed with a single $ expire automatically when the script runs out. 1
Lee Smith Posted September 11, 2012 Posted September 11, 2012 It is my understanding that the $variable value is always returned to a null value after the script been ran. FMP Help 1
James Gill Posted September 11, 2012 Author Posted September 11, 2012 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...
comment Posted September 11, 2012 Posted September 11, 2012 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.
James Gill Posted September 11, 2012 Author Posted September 11, 2012 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.
dansmith65 Posted September 11, 2012 Posted September 11, 2012 check this out: http://www.fmfunctions.com/functions_display_record.php?functionId=160 Not that you have to use a custom function for this, but it will at least show you how to do what you want.
comment Posted September 11, 2012 Posted September 11, 2012 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. 1
dansmith65 Posted September 11, 2012 Posted September 11, 2012 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 ).
Fitch Posted September 11, 2012 Posted September 11, 2012 There probably is a much simpler way to accomplish whatever this is supposed to accomplish. Yes.
David Jondreau Posted September 12, 2012 Posted September 12, 2012 (edited) 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 ; "$$" & 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 September 12, 2012 by David Jondreau
Recommended Posts
This topic is 4512 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