Ultimate Find / Continue & Cancel pt. 2
Subtitles of the Movie
We still have our script paused. Let's fix that. We'll Cancel it. We'll Edit Layout Mode and then come over to our Customers Find layout and let's double click on this. You can see why it's paused, because it says pause the current script. What is it referring to in this instance? Well, it's referring to your Find script, so it says run this script, so when you click on that button, run the Cancel Find script, and then pause the current script, or the Find script. That's the most common choice and you'll leave most of your scripts on there like that, but there are other choices, such as Resume. What this does is says run the Cancel Find script, then click the Continue button and continue running that Find script. That's not what we want. I have used it before, but that's not what we want in this situation. We either want Exit or Halt. Halt script says stop all scripts that are running. So, in other words, run the Cancel Find script and then halt the Find script or any other script that might be running, even Subscripts, but if we choose Exit and we happen to put a Subscript on our Find and it happens to be in the Subscript, Exit is going to exit the Subscript and then return to the calling script. So that's not a good choice here. I almost always choose Halt because I want to stop everything. So this works great. We'll go with this and see how that works. We'll come back to Customers Form and we'll go back into Browse Mode and let's try clicking that. We'll hit Cancel and notice that our script is no longer running, which is great. We don't want the script running anymore if we hit Cancel. Now, one thing I'm not satisfied with is that global variable, so if we go into our Data Viewer, if you have FileMaker Advanced. You don't really need FileMaker Advanced; we're just going to look. You can see that our global variable with a value of 1, because we started out on Layout number 1, is still there. If we have lots of global variables, we'd fill this in and really defeat the purpose of what we can do with the Data Viewer. It gets all cluttered up with all these global variables, so if you can avoid them, avoid them. Here's a little trick to avoid this. So we're going to go into our script. We're going to come back into here and we're going to go into our Ultimate Find and we're going to come in here and remove this. There we go. We don't need that anymore. We'll save that, come into our Cancel Find. We want to go to layout number by calculation, so we're going to say Get Script Parameter. We've done script parameters. How are we going to get this script parameter over there? Well, here's how we're going to trick it into doing that. We're going to save this, come back to our Ultimate Find, and we're going to add that set variable back in there, but this time we're going to do a local. Dollar sign, Last Layout. A single dollar this time. Then Get Layout Number. So, when this script is done running, that's going to be gone, so we need to find some way to pass it. Well, we're going to do that with a script parameter, so let's save that, close this. We'll go into Layout Mode, come over to our Find layout, and what we'll do on this Cancel is on our optional script parameter, we'll say Pass dollar sign Last Layout. So the idea behind this is when we click on this button, it can access that local variable and passes the script parameter before it's destroyed, in other words, before it's gone, so we can pass it along. So now we don't have to use a global variable. Let's verify that this actually works. We'll go to Browse Mode, hit Find, hit Cancel, and it works great. It works without that global variable, so if you can avoid the global variable, then great. Sometimes you can't, but most of the time you can. In fact, I hardly ever use them because I don't want it to clutter up everything and worry about what's being taken up in memory. It's just much easier, in my opinion, to use local variables because they're initialized for you at the end of the script.
Tutorial Information
| Course: | FileMaker Pro 10: Advanced |
| Author: | John Mark Osborne |
| SKU: | 33927 |
| ISBN: | 1-935320-20-3 |
| Release Date: | 2009-01-05 |
| Duration: | 12 hrs / 150 lessons |
| Work Files: |
Yes |
| Captions: | Available on CD and Online University |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |
VTC Sign up & Benefits
- Unlimited Access
- 81,350 Video Tutorials (20,800 free)
- Video Available as Flash or QuickTime
- Over 782 Courses
- $30 for One Month Access
- Multi-User Discounts Available
United States 