Script triggering with validation.... (and how to use quotes?)
While I'm extremely impressed by the plugin, I'm also frustrated at the difficulty I often find with getting the syntax exactly correct. Particularly where single and double quotes are concerned. This is only made more challenging by the fact that I just don't use the plugin that often, (once I have a trick working, I don't usually have to go back and visit it) so I will often forget what I learn about it.
What would be helpful is some documentation on where to use which quotes depending on context. I've noticed that if I run code (like the testbed file) where the php_execute() is in one field and the code is in another, the requirements for the quotes seems to be different from when the code is actually entered in a calculation. Field names versus lines of code..... escaped or not....
I'm working on a validation that should trigger a script, but for the life of me, I can't get Smartpill to execute one when the value in the field changes.... and I'm sure it's related to the strings that i'm not getting right.
and the fog cleared...
Thanks so much for the help. That helps clear things up, and the custom function is wonderful. Thanks again!
bill
Custom function for script triggering
In general, I try to use single quotes because it makes things easier but sometimes you have to use double quotes for things like "\n". We typically use the testbed file for development and then if we need to paste the code into a FM calc, we run the code through a substitution calc:
Substitute ( code ; [ "¶" ; "\¶¶" ] ; [ "\"" ; "\\\"" ] )For script triggering, we use a custom function:
/*NAME:
_TriggerScript
HISTORY:
Created: 30-NOV-2006 By Dawn Heady
PURPOSE:
Used to trigger a script; makes use of the SmartPill plug-in.
PARAMETERS:
script
file
parameter
controlName - optional parameter; accepts: halt, exit, resume, pause (default)
NOTES:
This custom function should be in all interface files.
POSSIBLE ERRORS:
*/
Let (
[
qt = "\"" ;
controlNum = Case ( controlName = "halt" ; 0 ; controlName = "exit" ; 1 ; controlName = "resume" ; 2 ; 3 ) ;
phpCode = "fm_perform_script( " & qt & file & qt & ", " & qt & script & qt & ", " & qt & parameter & qt & ", " & controlNum & ");"
] ;
PHP_Execute( phpCode )
)
Hope that helps end the frustration.
Regards,
Micah