Jump to content

[TIP] Personal Script Paramater Parser...


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

Recommended Posts

Now that we can pass a bunch of stuff via the script parameter I hate having to create a calc to parse it out every time...

I created the following Custom Function:

My_Scripts ( value )

Substitute ( MiddleValues ( Get ( ScriptParameter ) ; value ; 1 ) ; "

Link to comment
Share on other sites

  • 2 weeks later...
  • Newbies

Hi guys: As with all things FM; there is another way to do this as well. Download the "Split" CF on Dunning's site and you can use this not only on script params, but elsewhere as well. The CF allows you to decide the split character on-the-fly. A script param may look like this: abc|pwr|xyz. You can get this in your script with a specification like this: Split ( Get ( ScriptParameter ); 2; "|" ) -> returns pwr.

Link to comment
Share on other sites

  • 4 weeks later...

I didn't invent this, but I found it so useful and elegant I began using it with the solution I just began building.

Here's the custom function:

// This system passes parameters to scripts in the form of "Parameter1 = "Param1"; Parameter2 = "Param2"".

// This function will extract the named parameter from the full script parameter, so that calling, when the above

// was passed, GetParameter( "Parameter1" ), will return "Param1".



Evaluate( "Let ( [ " & Get( ScriptParameter ) & " ]; " & ParameterName & " )" )




This is from the Using FileMaker 7 book. Number of parameters are effectively unlimited, can be in any order. Escaping the quotes makes string parameters a bit difficult to read, but I quickly got used to that. I used to use the pipe character as my delimiter, but find this much more flexible.



BTW, another technique I use is that when my scripts require a parameter, I place parameter names in parentheses. For instance, I have a script called "Edit Record( TableName, RecordID )" which is meant to take two parameters. Assuming I'm editing a address record that appears in a portal from a contacts table, I could call this with a parameter that looks like:




"TableName = "Addresses"; RecordID = "" & AddressesForContacts::AddressID & """

Chuck

Link to comment
Share on other sites

  • 1 year later...

This topic is 6738 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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