Jump to content

How To Get Script Parameter by Number

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

Recommended Posts

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

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.


MiddleValues( Substitute( Get(ScriptParameter); [

Link to comment
Share on other sites

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 smile.gif 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

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.



Link to comment
Share on other sites

  • Create New...

Important Information

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