Solved

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

Posted on 2011-03-18
5
698 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
  • 2
  • 2
5 Comments
 
LVL 2

Author Comment

by:rvfowler2
Comment Utility
Attachment.
-PassingVariable.JPG
0
 
LVL 24

Accepted Solution

by:
Will Loving earned 333 total points
Comment Utility
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 24

Assisted Solution

by:Will Loving
Will Loving earned 333 total points
Comment Utility
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 167 total points
Comment Utility
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
Comment Utility
Theory and example looks good.  Will eventually implement, but caught up elsewhere right now.  Thanks to both.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Conversion Steps for merging and consolidating separate Filemaker files The following is a step-by-step guide for the process of consolidating two or more FileMaker files (version 7 and later) into a single file with multiple tables. Sometimes th…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now