• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Lesson 28. Date Conversions > Creating a Date Calculator

Creating a Date Calculator

Now you'll use Director's date functions to create a date calculator.

Choose File > Open to open Start.dir from the Start folder in the Lesson28 folder (Windows Ctrl+O, Macintosh Command+O). Save this file as Datecalc.dir in your Projects folder.

The Start movie comes with the interface prebuilt for you, but you will need to write all of the Lingo code to make if functional.

If the stage is hidden, choose Window > Stage to display the stage (Windows Ctrl+1, Macintosh Command+1).

The elements are all visible except for three response fields: the current date and the calculated values that will appear to the right of the two date calculation buttons. Although they are on the stage, you can't see them yet because they use Background Transparent ink and they won't appear until they have some information stored in them.

Figure .

When the calculator is complete, it will display today's date when you run it. It also has two sets of fields for entering year, month, and day information, and two buttons for performing calculations. The top button will compare the current date with the date entered in the top date fields. The second button will compare the two user-supplied dates.

Play the movie and click each of the date calculation buttons on the calculator.

Although the movie is playing, you don't see today's date, and clicking the buttons does nothing. There are sprites on the stage, but they don't include the Lingo code necessary to support the date functions. This is what you need to add.

Now take a look at the cast.

Choose Window > Cast to display the Cast window (Windows Ctrl+3, Macintosh Command+3).

Figure .

Cast members 1, 2, and 3 are empty (you will enter a script in cast member 1), and cast member 4 is the prompt for today's date. Cast members 5 and 6 are the two date calculation buttons, and cast members 7, 8, and 9 are the Year, Month, and Day prompts.

Cast members 10 through 18 are all text fields, as indicated by the text field icon at the lower right of each; these are titled Today, Result1, Result2, To Year, To Month, To Day, From Year, From Month, and From Day, respectively. The user will be entering values into some of these fields, and your scripts will have to refer to these fields by name to retrieve those values.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint