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
Solved

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

Posted on 2011-03-18
5
707 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
ID: 35165369
Attachment.
-PassingVariable.JPG
0
 
LVL 25

Accepted Solution

by:
Will Loving earned 333 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 333 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 167 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Pop up windows can be a useful feature of any Filemaker database.  Though best used sparingly, they can be employed in a multitude of different ways, for example;  as a splash screen at login, during scripted processes to control user input, as pick…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

766 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