Custom Dating: A Lesson In AbstractionPosted by: Editor / Friday, May 30, 2003 – 9:23am
Read full article below
This technique file shows you how to best implement Toggle buttons into your interface. Click the links below to get a copy of the files and watch the video. You MUST be logged into the site in order to see the download files If you are getting a Bad Argument API error please see the help page by clicking here. Note for Windows IE Users: If you are prompted for an additional password when starting the download enter these values. User = temporary Pass = password Click Watch Movie to view Watch the movie QuickTime from Apple Computer is required to watch the movie. Download Macintosh File Download Windows File Macintosh Internet Explorer Users! In order to properly download the file you must Control-Click on the "Download Macintosh File" link and rename to Toggle.sit. This will allow you to uncompress the file. Also note Internet Explorer for Macintosh is not an optimized browser for today's standards. The movie may not play instantly. Whereas with Safari or Camino your results will be better. We suggest these browser for Macintosh users. © Copyright 2003 - ISO Productions, Inc. - All rights reserved
Custom Dating: A lesson in abstraction Flexibility is key It's all about flexibility in the user interface. Empower users and the only task left for the developer, after the development, is education. In this technique I show you how to provide a level of abstraction that allows users the flexibility for formatting dates and times however they choose. You have two options for this article. You can read the article here or watch the video. This solution applies to any situation where information will be merged into some type of output, be it an outgoing email, a mail merge letter or custom interface control at a user level. Abstract from the code below When you think about your application and what it needs to provide within the user interface, it's always wise to abstract the code found in the calculation dialog box from what might be useful to the user. The code below the user interface is what you control as a developer, however, in many cases you need to provide some level of control to the end user. In this solution we take some common values such as a date field and time field and we create a level of abstraction that allows the end user to control what the date looks like. For example, take the following format of a date. Thursday, May 29 2003 at 3:27 PM In terms of how you format a date field in FileMaker Pro to achieve this result, it requires that you have access to layout mode and the ability to double-click on a field to actually change the hard coded settings for the resulting output. But here comes Ingrid and she's not from the United States, she's from Europe and likes to see her dates in a completely different format. Something more like this. 29. May 2003 - 15:27 So how can you program flexibility into your solution? Simple, you abstract. Creating the legend In many other programming languages and some software programs, you have the ability to specify the date format you desire. Sometimes it can be quite granular, down to each date element, and other times it's a matter of specifying a preset format such as dateLong or dateShort. Ultimately, you have options, and this all depends on the environment you are working in. However, with FileMaker Pro, formatting is hard coded at the layout level and we have to make our own legend for how dates can be formatted if we want this type of control. This is easily done though. Below is the legend I designated in the code you'll find in the associated technique file named Custom Dating. (Just a tip for fun: for those of you who are currently single, or even married, Custom Dating may be one method of abstraction but don't succumb to the distraction which is the lure of FileMaker Pro. It's not healthy to your own Custom Dating situation if you spend too much time in front of a computer) So, here's the legend I use.
%dnl = Tuesday (Day Name Long)
%dd = 03 (Day number with preceding zero)
%h2 = Hour (24 hour format) By using the legend above you can now write a FileMaker calculation that will pull out each of the various parts of a date or time field by using the built in functions dealing with dates and times. The resulting calculation looks like the following. (Note: I have used white space to differentiate the date formatting from the time formatting if you don't need both in your calculation)
Substitute(
Substitute( InputText,
"%dd", Right("00" & Day(Date),2)),
"%h2", Hour(Time)), User control is cool As you can see, what is now provided is a level of control where the user can specify whatever type of format they wish for dates to appear in. All you need is one input field, whichever date and or time field you'll be referencing and an output calculation field. The result is a very specific, user controlled, format for date and time values. By incorporating a Users file into your solution you can now allow a user to choose a format for how dates and times appear - without having to give access to layouts. One of the caveats to this solution is that it works best with merge fields placed on the layout. If you are attempting to display a formatted date within a field (based on this technique) then it will require the addition of one calculation field for each field you wish to format (inclusive of both a date and time field or either one individually). So, for example, if you have a date field and you wish for the user to be able to control the formatting that it shows, then they might do so in a preference field on their given user record. Then, with a non-enterable calculation field (unstored) placed on top of the actual date field you can display the date, or time, according to how the user has specified. (Developer Tip: You can also use merge fields on top of regular fields. Simply give them an opaque fill and you don't have to worry about messing with setting a calculation field above your normal field to non-enterable) Users can also use the legend to format other fields such as subject lines for email or dates found in merge letters that are printed out. Just make sure and give your users a shove in the right direction by providing them with some help about finding and using the legend. Examples always seem to work well. Overall, this is a great technique for showcasing how abstraction allows you, as a developer, to provide more control in your user interface. Don't stop with just dates and times. Any situation where you have some data that a user needs to control the resulting output, you can abstract by creating a legend, or data map, for how the input should be converted into the output. Just make sure and use legend values that won't show up in the normal data!
Enjoy! Filed under: articles
|
Be notified!Sign up for any of our notification lists for the quickest notification of new items! FileMaker Reference Tool10 Most Recent Videos
|