Jump to content

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

Recommended Posts

Posted

Instead of taking my vitamin this morning I think I took a stupid* pill--I'm staring at a simple Let function as a script parameter and I just don't get it. I watched Matt P.'s fine video about the Let function and after the 26-minute presentation I'm still dumbfounded...which anyone can see: it's the classic FileMaker Pro 20-inch stare. (Twenty inches from my nose to the monitor.)

 

Here it is:

 

Let ($$deleteRecord = ADDRESS::_kpln__AddressID; "DeleteRecord" )

 

 

I get it that $$deleteRecord is equal to the key field ID number in the Address table. Fine...but after the semi-colon, what's the function of "DeleteRecord"? Is it considered the second part of a multiple parameter that's handed off to the next script, or...?

 

Another thing: Since I'll be handing off the parameter to two other scripts (after the current one runs), would a single dollar sign ($) suffice or do I really need to make it a global variable with two dollar signs ($$)? I want to be educated about this point since I read in other blogs that global variables can be problematic sometimes.

 

Thanks in advance for your replies.

 

 

 

*Stupid as a noun, not an adjective.

Posted

The last term in a let function is the output; the value that gets returned after the let function is evaluated.

 

See the Examples section of Help for the Let function:

 

http://www.filemaker.com/12help/html/func_ref3.33.16.html#1028226

 

What do you observe when you build a script according to his technique, and then watch the data viewer while you trigger the script and step through it?

 

I have not viewed the video but it would appear that the technique uses two different methods to pass info to a script.

One part is the script parameter (result of let function) and the other part is the declared global variable.

If so, it appears to be a technique that is limited to calling same-file scripts.

 

It is valid to define an empty result it that meets your need. If your intent is to create four $$ variables you can just do:

 

Let([ $$top = 0; $$left= 0; $$right = 100; $$bottom = 200]; "")

Posted

The script variable (single $) only works within its own script and then politely disappears.

The global variable (double $$) persists until you kill it (clear it). The $$ can be seen by other same-file scripts but cannot be passed to scripts in another file.

 

A global FIELD can be "seen" from any file.

 

Seems preferable (IMHO) to pass a complete parameter.

Posted

We recently added a page with some best practices for Let notation to FileMakerStandards.org.

 

I'm not sure what the purpose of the "DeleteRecord" Let result is outside the context of the script containing that calculation, but I'd guess that it was intended to serve as some kind of code comment or debugging aid.

 

My opinion is that it's a better habit to use local variables for this sort of thing. It minimizes side effects with potential unforeseen consequences. In a set of custom functions dansmith65 and I worked on, the main function for evaluating Let notation even coerces global variables to be local.

Posted

What do you observe when you build a script according to his technique, and then watch the data viewer while you trigger the script and step through it?

 

That's the curious thing: the key field ID number appears (as it should) while stepping through the viewer, but "Delete Record"? Nada.

 

Thanks, everybody, for your input. What I wasn't clear about in my original message was that I watched Matt P's vid to try to educate myself about the Let function; the coding I'm bringing to your attention is from a file recently handed to me, not from his vid.

Posted

If you didn't see "DeleteRecord" in the data viewer then you need to learn how to follow instructions, and how to use script parameters, the debugger and the data viewer.

 

You said the video instructed you to use the let statement as the script parameter.

 

Let ($$deleteRecord = ADDRESS::_kpln__AddressID; "DeleteRecord" )

 

If you DID do what the video instructed, then any get(scriptParameter) statement in the target script would have resulted in "DeleteRecord".

ParamTest.fmp12.zip

This topic is 4315 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.