Jump to content

  •  

UPGRADE DEADLINE - SEPTEMBER 26, 2014!
FileMaker Inc. has a deadline for users of version 10,11, 12 as Individual box or volume licenses (with expired maintenance).
If you don't renew your maintenance and upgrade to FMP 13 you will no longer be eligible to upgrade, at the discount pricing.

Volume Licensing upgrade pricing for FileMaker Pro 13, FileMaker Pro 13 Advanced and FileMaker Server 13 will be discontinued.
Individual upgrade pricing for FileMaker Pro 13 and FileMaker Pro 13 Advanced will increase after September 26, 2014.
As of 27-September-2014, FileMaker 10 products will no longer be available for purchase or support.

http://help.filemaker.com/app/answers/detail/a_id/13865


Photo

Global vs Local Variables


  • Please log in to reply
2 replies to this topic

#1 JonAgnew  member

JonAgnew
  • Members
  • 16 posts
  • FM Application:11 Advance
  • Platform:Mac OS X Snow Leopard
  • Skill Level:Novice
  • Membership:TechNet
  • Time Online: 1d 2h 1m 26s

Posted 15 February 2012 - 02:37 PM

Hey, guys. Just a quick question for clarification. I have a script that involves a lot of IF statements. I want to make a sub-script that I can call via Perform Script, so I don't have to have a 1000 line script. If I set variables in the main script that I want to use in the sub-script, do I need to set those to global variables?
  • 0

#2 dansmith65  veteran

dansmith65
  • Members
  • 858 posts
  • LocationB.C. Canada
  • Certification:8, 11, 12, 13
  • Membership:TechNet
  • Time Online: 14d 23h 52m 41s

Posted 15 February 2012 - 03:15 PM

If you were to use variables, yes.

An alternative would be to pass the values to the sub-script in the script parameter, but if you want to pass multiple values, then you will need a method to manage that. There are plenty of options for this, my preferred method is: http://sixfriedrice....nary-functions/
  • 0

#3 Fitch  Imaginary friend

Fitch
  • Moderators
  • 4,025 posts
  • LocationPortland, Oregon
  • FM Application:13 Advance
  • FMGo:iPhone / iPod Touch, iPad
  • Platform:Cross Platform
  • Skill Level:Expert
  • Certification:7, 8, 9, 10, 12
  • Membership:TechNet
  • Time Online: 16d 9h 42m 43s

Posted 16 February 2012 - 12:50 PM

It's OK to use global variables, but... If you do, keep in mind that they are file-specific, so it won't work if the sub-script is in a separate file. Another potential drawback is that you have to clean up after yourself, as a persistent value in a global variable could have unintended consequences.

For those reasons, I generally prefer to pass script parameters as Dan suggested. I use this method, which is a little simpler than the 6FR way, which requires a function both to send and receive the params. The one I use only uses a function to receive the params.
  • 0
Tom Fitch :: Portland, Oregon :: Fitch & Fitch: FileMaker consulting




FMForum Advertisers