In the Intermediate tutorial we covered how to format a phone number field using the Filter function, Let function, Case statement, Left, Middle and Right and Length functions. We also tried a Plugin that comes with FileMaker 10 Advanced so let's take a moment to refresh your memory before we go into how Recursion will work with this Phone filter. So we'll go into Manage, Database, we'll come down to our phone field, it's right there, we'll go into Options, and the first thing we want to remember, to refresh your memory, is we unchecked this option, that's so whenever you type in a new phone number it will automatically calculate and format that phone number. If we didn't have this unchecked then it would only do it when that field was blanked. We'll have it unchecked so it continuously auto enters over whatever you've typed as soon as you exit that field. And then we go into it, here's our formula and we start off with the Let function and then we make a Declaration because we're going to use this code that follows many times throughout this formula and what we do is we'll say Filter Self, which is the phone field and just keep the numbers and the reason we did that is so we didn't have any formatting in there so we could see how many numbers have been entered and easily parse out those numbers. Now we'll get back to the TextFormatRemove in a second to remind you about that, but this is the main idea is take out all the formatting so we can easily work with that, parse that phone number so we can put in the right formatting so we can have it all consistent. So then we start into a Case statement, we say check to see if At Numbers, just the numbers, equal 10 digits. If it does we go ahead and take the first 3 characters from the Left, the Middle 3 characters and the last 4 characters and put dashes in between it, but you can put any format in here you want. If we had a length of 7 that means they didn't enter an area code and we accounted for that and said put in our local area code and you can do whatever you want here plus the other 7 digits. And if it was neither 10 or 7 digits that means they typed in something wrong and what we're going to do is highlight that in red, turn all the text red but put in exactly what they typed in, don't take out the formatting, that's why we're using the Self function and not At Numbers here. And, if that happens, that's why we need TextFormatRemove here because if we go ahead and modify it and put the right number of digits we want that text to turn black again and not be red, so we had to remove all the formatting. So that's a pretty good little technique. You can see the ending of the Left function in the Case statement here and the idea behind this calculation is that it's all within FileMaker so that's a benefit. You can type it in, it's easy to understand. The problem with it is, that it's not very flexible. We could make it more flexible to handle more lengths of numbers but we have 10 and 7 basically here and that would handle most people's situations but if you want something a little bit more flexible, something that's versatile, you want to go with the Plugin, so I'll hit a couple returns here and remind you what the Plugin looks like, the one that comes with FileMaker 10 Advanced and we go down to External functions, we'll see it in here in the FileMaker Example, we'll see FormatNumber. We'll double-click on it and you'll see it needs a string and a text or number, so we would provide it with Self here and then in here we'd type in quotes whatever formatting we wanted. We could do something like this. Now the pounds equal the numbers, anything else is formatting, which it keeps. So we'll want to have that and then four pounds - oops, got a space in there - and then a close quote. So, the great thing about this is you can come in and easily change this formatting. We could put in international numbers here by adding more pounds in different formatting. It's flexible enough that you can come in here, in fact, you could provide this with a preferences area and have people pop-up a menu and provide this with the contents of the field, but you can see how much more flexible it is, it handles anything, what you throw at it as long as you have the right formatting in here. The problem is, with the Plugin, is that you have to have the Plugin, you have to install it. You have to make sure that you get upgrades, you know, you have to make sure it's on everybody's machine and in general I think that you can do just as well with this technique but program it yourself so it's all contained within FileMaker, so this is our goal here. We want to make something that works like FileMaker in this regard. We want to make something that works like the Plugin in FileMaker. So, we're going to come over here and remove that and what we're going to do is remove a lot of this stuff. We're going to come here and take out most of this stuff, hit a return, close that Let function, and we'll come in here and show you how we might do it with the Case statement. Now a Case statement is not what we're going to end up with, we're going to end up with Recursion, but I want to show you what a Case statement would look like and try to replicate this. So we'll come in here and we'll add another parameter. First we'll take out this close paren here - actually we need that one right there. We've got 1, 2, 1, 2, so that's perfect, but we need another one here and that will be At Format equals and then you type in whatever formatting you want. This gives the flexibility that you have with the Plugin. You can change this to whatever you want, provide it with a field, however you want to do this and there's the flexibility. And we need to also put our brackets in here because we have two parameters now and then we go into our formula, which would be a Case statement and actually quite a few Case statements. We start off with Left At Format, the first character, does it equal a pound? If it does, if we look at this format and it's a pound then we need to take one of the numbers out of the Self function or out of the AtNumbers only. So we come in here and we say: Left AtNumbers, semicolon 1, close paren, otherwise it must be some type of formatting that doesn't need a number in there and so we say Left AtFormat 1 close paren, close the Case statement and then do an ampersand here. Then we'd hit the Return and start over again. Case open paren, this time we'll have to use the Middle function, AtFormat semicolon 2, semicolon 1 to get the second character, equals pound. If it does, get the Middle Number 2 semicolon 1, close paren, semicolon and then otherwise get the formatting, AtFormat semicolon 2 semicolon 1 close paren close paren ampersand and now to make things easier we're going to copy and paste and this isn't too difficult. You just need a bunch of Case statements and we come in here and we say 3, 3 and 3 and then we paste again and we keep on going down this road until we have enough to handle the maximum number of formatting and you'd probably want to do more than you'd ever need just to be sure and it certainly will work. Once you're done you don't need an ampersand on the last one and there's your formula. But we'd have to obviously go on further here. The problem with this is it's not flexible. If you need to make a change there's a whole bunch of Case statements here. I like to have something that loops through it, that's what Recursion does, it can say run this formula over and over and over again, this basic formula, so it's easier to edit once you get it into and it's much more flexible and that's what we're going to be going is with Recursion, just to show you how to do and this shows you what Recursion's about. Recursion's about doing essentially one Case statement over and over and over again rather than a whole bunch of Case statements that have a limit as to what they can do. Recursion has no limit. It can go - well, it does have limits, it's limited to either 10 or 50,000 recursions depending on how you do it, but the idea here is that with the Case statement you're definitely limited and it's a much lengthier piece of code that may need, if you have to go back and change one thing, everything, it can be a real pain. So let's take a look at Recursion in the next section.
TERMS & CONDITIONS OF USE
BY SUBSCRIBING TO THIS SERVICE, YOU ARE CONSENTING TO BE BOUND BY AND ARE BECOMING A PARTY TO THIS AGREEMENT, THE TERMS AND CONDITIONS OF WHICH SHALL PREVAIL IN GOVERNING YOUR RIGHTS OF USE. BY CLICKING THE "BECOME A MEMBER" BUTTON, THE INDIVIDUAL OR ENTITY LICENSING THE PRODUCT ("YOU") IS CONSENTING TO BE BOUND BY AND IS BECOMING A PARTY TO THIS AGREEMENT. IF LICENSEE DOES NOT AGREE TO ALL OF THE TERMS OF THIS AGREEMENT, THE BUTTON INDICATING "BECOME A MEMBER" MUST NOT BE SELECTED, AND LICENSEE MUST NOT INSTALL OR USE THE SOFTWARE.
"VTC" refers to Virtual Training Company,
"You" refers to the user or subscriber.
"Software" refers to the VTC training content and software.
2. LICENSE: VTC hereby grants to You a worldwide, non-royalty bearing, non-exclusive license to use the Software according to the provisions contained herein and subject to payment of the applicable subscription fees.
3. RESTRICTIONS: You may not do any of the following:
Save the Software to Your hard disk or other storage
medium; permit others to use the Software except as specified by addendum;
modify, reverse engineer, decompile, or disassemble the Software; make
derivative works based on the Software; publish or otherwise disseminate
the Software. VTC, Inc., VTC Online University, and the Virtual Training
Company site is owned and operated by VTC, Inc. as a corporation of
All materials on this site are the property of VTC unless otherwise specified. No material from these pages may be copied, reproduced, republished, downloaded, uploaded, posted, transmitted, or distributed in any way. Modification of the materials or use of the materials for any other purpose is a violation of U.S. copyright law and other proprietary rights. For purposes of this Agreement, the use of any such material on any other web site or networked computer environment is prohibited.
4. FEES: The rights granted under this Agreement
are effective only upon payment of the subscription fees, which are
strictly non-refundable other than as expressly provided herein. The
term "monthly subscription" is defined as any 30 day period.
The term "yearly subscription" is defined as one 365 day
period. A yearly subscription ends on the same numerical date as it
began (example July 28, 2004 to July 28, 2005).
The VTC Online University is access to every VTC training tutorial in our library. You pay a flat fee for access to these titles. You are billed according to your renewal selection below, and can renew monthly, yearly, or in any other increment offered. If you choose to be billed monthly, you will be billed every 30 days for the subscription until you request the subscription be cancelled. Our terms of service state that you must cancel a monthly subscription at least two business days before your renewal date. These two days give us enough time to ensure that you will not be charged again.
5. LIMITED WARRANTY: VTC warrants that the Software, if operated as directed, will substantially achieve the functionality described. VTC does not warrant, however, that Your use of the Software will be uninterrupted or that the operation of the Software will be error-free or secure. In addition, the security mechanisms implemented by the Software have inherent limitations, and You must determine that the Software sufficiently meets Your requirements. VTC also warrants that the media containing the Software, if provided by VTC, is free from defects in material from the date You acquired the Software. VTC's sole liability for any breach of this warranty shall be, in VTC's sole discretion: (i) to replace Your defective media or Software; or (ii) to advise You how to achieve substantially the same functionality with the Software as described; or (iii) if the above remedies are impracticable, to refund the subscription fee You paid for the Software. Only if You inform VTC of Your problem with the Software during the applicable subscription period will VTC be obligated to honor this warranty. VTC will use reasonable commercial efforts to repair, replace, advise, or refund pursuant to the foregoing warranty within thirty (30) days of being so notified. If any modifications are made to the Software by You during the warranty period; if the medium is subjected to accident, abuse, or improper use; or if You violate the terms of this Agreement, then this warranty shall immediately terminate. This warranty shall not apply if the Software is used on or in conjunction with hardware or software other than the unmodified version of hardware and software with which the Software was designed to be used as described.
THIS IS A LIMITED WARRANTY, AND IT IS THE ONLY WARRANTY MADE BY VTC OR ITS SUPPLIERS. VTC MAKES NO OTHER WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF THIRD PARTIES' RIGHTS. YOU MAY HAVE OTHER STATUTORY RIGHTS. HOWEVER, TO THE FULL EXTENT PERMITTED BY LAW, THE DURATION OF STATUTORILY REQUIRED WARRANTIES, IF ANY, SHALL BE LIMITED TO THE ABOVE LIMITED WARRANTY PERIOD. MOREOVER, IN NO EVENT WILL WARRANTIES PROVIDED BY LAW, IF ANY, APPLY UNLESS THEY ARE REQUIRED TO APPLY BY STATUTE NOTWITHSTANDING THEIR EXCLUSION BY CONTRACT. NO DEALER, AGENT, OR EMPLOYEE OF VTC IS AUTHORIZED TO MAKE ANY MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS LIMITED WARRANTY.
6. PROPRIETARY RIGHTS: VTC reserves all proprietary rights in and to the Software, is protected by copyright and other intellectual property laws and by international treaties. VTC, Inc.
Trademark Notice: VTC, Virtual Training Company,
Inc., The VTC Logo, and VTC Online University, are trademarks of VTC,
Inc. All other company and product names may be trademarks of their
The information contained herein is subject to change without notice. Copyright © 1995 - 2005 VTC, Inc. All rights reserved.
7. TERMINATION: This Agreement shall automatically terminate if You fail to comply with the restrictions described herein. Your obligations to pay outstanding subscription fees shall survive any termination of this Agreement.
8. LIMITATION OF LIABILITY: UNDER NO CIRCUMSTANCES
AND UNDER NO LEGAL THEORY, TORT, CONTRACT, OR OTHERWISE, SHALL VTC
OR ITS SUPPLIERS OR RESELLERS BE LIABLE TO YOU OR ANY OTHER PERSON
FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF
ANY CHARACTER, INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
COMMERCIAL DAMAGES OR LOSSES. IN NO EVENT WILL VTC BE LIABLE FOR ANY
DAMAGES IN EXCESS OF THE AMOUNT VTC RECEIVED FROM YOU FOR A LICENSE
TO THE SOFTWARE, EVEN IF VTC SHALL HAVE BEEN INFORMED OF THE POSSIBILITY
DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM VTC'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
9. Links To Other Materials: Linked sites found at the VTC site are not under the control of VTC, and we are not responsible for the content of any linked site or any link contained in a linked site. VTC may change links based solely on our discretion, and we reserve the right to terminate any link or linking program at any time. VTC does not, by linking to sites, endorse companies or products to which it links and reserves the right to note as such on its web pages. If you decide to access any of the third party sites linked to this site, you do this entirely at your own risk.
Forums, and Chat are not always screened by VTC, and we are not responsible for the content of any public or open forum content at the site. VTC may change these public forums based solely on our discretion, and we reserve the right to terminate any forum at any time. VTC does not, by allowing these forums, endorse companies or products which may be mentioned in these forums, and reserves the right to note as such on its web pages. If you decide to access any of the public forums in this site, or linked to this site, you do this entirely at your own risk.
9. GOVERNING LAW & DISPUTE RESOLUTION: This Agreement is governed by Virginia law. All disputes between You and VTC shall be finally resolved through arbitration in Winchester, Virginia. This site is controlled by VTC from its offices within the United States of America. VTC makes no representation that materials in the site are appropriate or available for use in other locations, and access to them from territories where their content is illegal is prohibited. Those who choose to access this site from other locations do so on their own initiative and are responsible for compliance with applicable local laws. You may not use or export the Materials in violation of U.S. export laws and regulations. Any claim relating to the Materials shall be governed by the internal substantive laws of the Commonwealth of Virginia, USA.
VTC may revise these Terms at any time by updating this posting. You should visit this page from time to time to review the then-current Terms because they are binding on you. Certain provisions of these Terms may be superseded by expressly designated legal notices or terms located on particular pages at this Site.
If you have any questions regarding this policy,
or your information specifically,
you may email us at:firstname.lastname@example.org.