goldcougar Posted January 20, 2005 Share Posted January 20, 2005 We needed a solution to pass many parameters to a function, and to quickly retrieve them throughout the script. Our parameters also has spaces in them, so we used the "~" as a delimiter. We have a custom function called: getScriptParameter( parameter ; number) The code for the custom funciton is: If ( number=1;Left (Get(ScriptParameter); Position (Get(ScriptParameter) ; "~"; 0 ; 1 ) -1) ; If ( number=(PatternCount ( parameter ; "~")+1) ; Right ( Get(ScriptParameter) ; Length(Get(ScriptParameter))-Position ( Get(ScriptParameter) ; "~" ; 0 ; PatternCount ( Get(ScriptParameter) ; "~" ) ) ) ; Middle ( Get(ScriptParameter); Position (Get(ScriptParameter) ; "~"; 0 ; number-1 )+1 ; Position (Get(ScriptParameter) ; "~"; 0 ; number )-Position (Get(ScriptParameter) ; "~"; 0 ; number-1 ) -1))) An example of use would be in on a button running a script and passing as parameters: myfield1 &"~" & myfield2 & "~" & myfield3 Then, when inside of the script, if you want to get the value of myfield2, you can call the custom function by using: getScriptParameter(get(scriptParameter); 2) The 2 just signifies getting the second parameter. For naming conventions on the scripts, we name them as: myScript(myfield1, myfield2, myfield3) so that you know what order the parameters go in. Link to comment Share on other sites More sharing options...
-Queue- Posted January 20, 2005 Share Posted January 20, 2005 Not to rain on your parade, but Substitute( MiddleValues( Get(ScriptParameter); Number; 1 ); Link to comment Share on other sites More sharing options...
goldcougar Posted January 23, 2005 Author Share Posted January 23, 2005 Yes, we started with that, however we started passing big text strings, and even some with paragraph breaks, so using the paragraph symbol didn't work from us...so we used the "~". Link to comment Share on other sites More sharing options...
-Queue- Posted January 24, 2005 Share Posted January 24, 2005 In that case, all you need to do is convert the carriage returns into nonsensical strings, the tildes to carriage returns, and then convert the strings back to carriage returns after the string is parsed. Substitute( MiddleValues( Substitute( Get(ScriptParameter); [ Link to comment Share on other sites More sharing options...
goldcougar Posted January 26, 2005 Author Share Posted January 26, 2005 Thats definitly another way to look at it. Which ever delimiter people try to use I think the custom function is the way to go...or maybe I'm just lazy But, if your passing an average of 4-7 parameters to each script, using the middle words and others gets old pretty fast...So, for us its nice to just be able to pass a string, and the number of the parameter you want to return to a custom function. Link to comment Share on other sites More sharing options...
Dr. Don Levan Posted January 26, 2005 Share Posted January 26, 2005 Hi All, There is one other way you can do this. Take a look at this posting on the custom Function forum at cleveland consulting's site. It talks about a way of using custom functions to establish a property list which allows you to set, retrieve, and pass multiple variables by name. http://www.clevelandconsulting.com/support/viewtopic.php?t=59 Don Link to comment Share on other sites More sharing options...
-Queue- Posted January 26, 2005 Share Posted January 26, 2005 Cougar, I agree. I just thought you might appreciate a simpler, more efficient one. Link to comment Share on other sites More sharing options...
goldcougar Posted January 26, 2005 Author Share Posted January 26, 2005 Thanks Queue. Don...Thats also a good technique. Accessing by name could definitly be useful. Link to comment Share on other sites More sharing options...
Recommended Posts