[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

FM - Passing More than One Variable in an Exit Script Step

Posted on 2011-03-18
5
Medium Priority
?
726 Views
Last Modified: 2012-05-11
I have created the subroutine below, since it is used in 3 different email scripts.  Rather than changing all the local $ variables to global $$ variables is there a way to pass more than one variable through the Exit script step?  I'm considering this because I've heard that global variables don't close until FM closes and thus uses a bit more RAM.  Thanks.
0
Comment
Question by:rvfowler2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 2

Author Comment

by:rvfowler2
ID: 35165369
Attachment.
-PassingVariable.JPG
0
 
LVL 25

Accepted Solution

by:
Will Loving earned 1332 total points
ID: 35165562
There's a really great way to do this that involves a simple custom function called "GetParameter()". It supports infinite user defined Script Parameters. For your multiple script parameters, you create a carriage return separated list in the following format:

List(
   "Parameter1=" & <the parameter value> ;
   "Parameter2=" & <the parameter value> ;
   "Parameter3=" & <the parameter value> ;
)

Then, in your script you simply use the Function GetParameter( "Parameter1") and it gets the value for whatever came after "Parameter1=" in the list up to the next carriage return. The Custom Function is as follows:

GetParameter( ParameterName ) =

Let(
   [
      ListOfParameters = "¶" & Get ( ScriptParameter ) & "¶";
      linestart = Position ( ListOfParameters ; "¶" & ParameterName ; 1 ; 1 ) + 1;
      paramstart = Position ( ListOfParameters ; "=" ; linestart ; 1 ) + 1;
      paramend = Position ( ListOfParameters ; "¶" ; linestart ; 1 ) - 1;
      paremlength = paramend - paramstart + 1;
      ValueOfParameter = Middle ( ListOfParameters ; paramstart ; paremlength);
      ValueOfParameter = Trim(ValueOfParameter)
    ];

ValueOfParameter

)

You can find more information on this Custom Function at: http://www.briandunning.com/cf/577
0
 
LVL 25

Assisted Solution

by:Will Loving
Will Loving earned 1332 total points
ID: 35165708
Here's an example of how I might use this with an email script. The script parameter might look something like this:

List(
"EmailAddress=" & Contact::Email1 ;
"EmailAddressCC=me@mydomain.com" ;
"EmailSubject=" $EmailSubject ;
"AttachmentPath=" & $FilePath
)

You'll notice two things here: 1) Parameters can reference fields (Contacts::Email1), variables ($EmailSubject") or just be entered text and 2) I didn't include the EmailMsgBody either as a field or variable. It's possible to do this, however, the issue is that email message almost always contain carriage returns and this is a return-delimited list. So, the way to include the Email Message Body is to wrap it in a Substitute statement that changes all carriage returns to something else like a single or double pipe "||". When you extract the passed variable in your generic email script you just need to reverse that process.

You also mentioned passing parameters on script exit using the Exit Script [] script step. This works exactly the same except that you need a slightly different Custom Function to extract the script parameters. I've created just such a custom function called GetResultParameter() - just a variation on the one above - that does this. It's available at: http://www.briandunning.com/cf/1202   So, instead of using Get( ScriptResult ) you use GetResultParameter() and it allows you to pull multiple named parameters just like GetParameter()

GetResultParameter ( ParameterName ) =

Let(
   [
      ListOfParameters = "¶" & Get ( ScriptResult ) & "¶";
      linestart = Position ( ListOfParameters ; "¶" & ParameterName ; 1 ; 1 ) + 1;
      paramstart = Position ( ListOfParameters ; "=" ; linestart ; 1 ) + 1;
      paramend = Position ( ListOfParameters ; "¶" ; linestart ; 1 ) - 1;
      paremlength = paramend - paramstart + 1;
      ValueOfParameter = Middle ( ListOfParameters ; paramstart ; paremlength);
      ValueOfParameter = Trim(ValueOfParameter)
    ];

ValueOfParameter

)
0
 
LVL 4

Assisted Solution

by:rjplus
rjplus earned 668 total points
ID: 35171356
Sometimes it easier to explain solutions to problems by viewing examples.  I have therefore attached a modified file originally created by FileMaker Guru, Darren Terry to demonstrate one of many ways to pass multiple parameters.  This particular technique was created by John Sindelar, Seedcode.  
I can also recommend the system used by Geoff Coffey at Six Fried Rice - using custom functions (this is my preferred method).  Hope this example file helps to illustrate the technique? Parameters.fp7
0
 
LVL 2

Author Closing Comment

by:rvfowler2
ID: 35180548
Theory and example looks good.  Will eventually implement, but caught up elsewhere right now.  Thanks to both.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem: You have a hosted FileMaker database and users are tired of having to use Open Remote or Open Recent to access the database. They say, "can't you just give us something to double-click on rather than have to go through those dialogs?" An…
Having just upgraded from Filemaker 11 to Filemaker 12 over the weekend, we thought we would add some tips for others making the same move.  In general, our installation went without incident. Please note that this is not a replacement for Chapter 5…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question