TweetFollow Us on Twitter

Calculating Distance
Volume Number:4
Issue Number:3
Column Tag:VIP Views

Calculating Distance for Navigation

By Bill Luckie, Contributing Editor, Simi Valley, CA

V.I.P. 2.2

Mainstay has released version 2.2 which is a significant upgrade and is free to all registered owners. V.I.P. 2.2 includes 25 additional procedures, improved keyboard control, 5 new intrinsic functions to provide added flexibility in handling Point and Rectangle objects, and the ability to create a true “About...” under the Apple menu. If you are a V.I.P. owner and haven’t sent in your registration card, you are missing some neat features.

In the beginning

In a previous article (April 1987), I presented a ‘shell’ program which implemented some of the common user interface actions e.g., Menus, Windows, File handling, and Events. In this program you will see that the same routines are used. In some cases these routines have been expanded to handle the specifics required of our program, and of course additional routines have been added. The only change brought about by changes to V.I.P. itself is the ‘About’ routine, which is now called Gee_Whiz. As mentioned earlier V.I.P. programmers can now create a “About (program name)” entry under the Apple menu and have it display whatever they choose. In this case selecting ‘About GC_Dist...’ displays the same window and information as presented at program startup.

The guts and feathers

The purpose of this program is to illustrate by example some of the most commonly used procedures. In addition to the already explored subjects we will create Dialogs, obtain user input data organized as records and save them to disk, work with some of V.I.P.’s intrinsic functions, and most importantly, have some fun programming. As is the case with most programs there is certainly more than one way to accomplish a particular objective. What I present here is not advocated as the only way, or even the best way, to do the job. In fact I violate a few of the rules set forth in Inside Macintosh, and I’ll tell you about them as we proceed.

Figure 1 Our Dialog Box

How far is it?

This program computes and displays the Great Circle distance between any two cities in the data file. Figure 4 contains the data required, which is input using the dialog as shown in figure 1. The Great Circle distance, in case you didn’t know, is the shortest distance between any two points on a sphere. It is most commonly used to represent the distance in nautical miles between airports for payload/range, performance, and fare calculations. Airports are each identified by a unique three character code. Los Angeles International airport, for example is LAX. The position on the globe of each airport is given as a latitude and longitude usually expressed in degrees and minutes. Latitudes south of the equator, and longitudes west of Greenwich, England are identified as negative angles. To work with these data, degrees and minutes are converted to decimal degrees, and to cope with SANE’s handling of some intrinsic functions, a conversion of decimal degrees to radians and vice is also required.

Learning to love rectangles

Three dialogs are used in this program. Record_Dialog, which is used to input the city code, latitude and longitude data. Edit_Dialog, which allows viewing and editing of the records previously saved to disk, and Input_Dialog for the user to specify the origin and destination city codes as input to routines for calculating the great circle distance.

V.I.P. allows the programmer to create dialogs using built in procedures as I have done in this example, or as resources created with a resource editor such as ResEdit or Dialog Creator. The difficulty in using V.I.P.’s procedures to create dialogs is in the visualization and placement of the various rectangles which bound each dialog item. Dialogs can contain static text, editable text, radio buttons, check boxes, and ordinary buttons, each situated within a rectangle. Creating complicated dialogs using V.I.P.’s procedures is enough to discourage ordinary mortals, but there is an easy solution even if you don’t care about resources.

My approach is to use Dialog Creator. Dialog Creator by Michael Bayer of Apple Canada lets you create dialog templates and dialog item lists interactively. It’s a simple matter to draw the dialog then print the text source file which gives you the coordinates of each rectangle and the assurance that your dialog will look OK.

For each of the three dialogs used in this program the code is essentially the same. A rectangle is specified for the size and location of the dialog window, and the new dialog procedure follows with arguments for rect, title, and dialog name. Entering a text string as the title argument indicates the dialog is to be non modal. Set rect and append dialog item procedures are now repeated for each item in the dialog. When referring to dialog items, their order of appearance in the dialog item list (DITL) is used.

By convention, dialog item #1 is the default action to be performed when the user presses the return or enter key generally signifying OK. (Note; this default action is implemented automatically in V.I.P. for modal dialogs only) When all dialog items have been appended to the list, the open dialog procedure displays the dialog on the screen. If you prefer to create dialogs as resources, then you will need to change all occurrences of kill dialog to close dialog so as to not erase them from memory until Quit is selected.

DoDialogEvent

Now that we have our dialogs created, we need to be able to process the information entered or displayed according to the users action. For example, in the dialog as shown in figure 1, you can see there are three editable text fields and two buttons. Data entered by the user in the text edit fields is saved to disk when the ‘Save it’ button is clicked, or conversely, the dialog is dismissed whenever the ‘Quit’ button is clicked.

The DoDialogEvent routine receives two input arguments, i.e. Dialog and item to direct the action to be taken depending on which dialog is active and which item of the dialog was selected. In this case the first if logic form is true, and program flow is directed to the Get_Record routine when item=1, and to the kill dialog procedure whenever item=2. Actions to be performed by the other dialogs are similarly handled.

The purpose of handling all dialog events in one routine is probably not apparent in this small program. However, this routine like those presented in my previous article, are really generic, in that they don’t do any real work, but merely direct program flow to a routine specifically designed to perform a discrete task. Programs written using a structured approach are usually easier to modify and are certainly easier to debug.

Get_Record

This routine when called by the DoDialogEvent routine simply executes three get dialog item procedures corresponding to the three text edit fields in the Record_Dialog. If you count the items appended to Record_Dialog you will see that items 7, 8, and 9 are the text edit fields receiving user entries for City Code, Latitude, and Longitude respectively. To assure the City Code is stored properly, the object ‘City’ is converted to upper case. When this routine has completed its miniscule tasks, program flow resumes in the DoDialogEvent routine and the Store_Records routine is called.

Figure 2 Editing our distance data base

Store_Records

With the information the user has entered in Record_Dialog extracted by the Get_Record routine as a result of the user clicking the ‘Save It’ button, we are now going to save it to disk as a record. A record, as I’m sure you know, is a group of related data organized in fields. In V.I.P., records themselves are identified by a Record Number, and individual fields are located within a record by specifying the offset (the number of bytes) from the beginning of the record. In preparation for storing the record to disk, the program decides if this is the first time its been asked to store a record, and if so, to display the standard file dialog, otherwise just save the record to disk without further ado. The first procedure sets the value of n according to how many times the routine is accessed, and is used as an argument to the object RecNo[n] which serves to automatically number our records.

The if (flag) logic form checks for true and directs execution flow accordingly. So, let’s say this is the first record to be stored. In that case flag=0 or false, and execution continues with the first else logic form. The get document name procedure displays the standard file dialog with the prompt, “Save file as ‘Cities’”. Here’s my first transgression from the scriptures of Inside Macintosh. Rather than allowing the user to name the file anything he (she) wishes, I tell ‘em name it ‘Cities’. If this offends your sensibilities, please feel free to change the code. Actually, you may name the file anything you choose. The argument name serves equally as the input argument, and its contents appear as the default name in the edit field reserved for the name of the file to be saved. To change the default name, initialize the global object ‘FileName’ to whatever you prefer, and don’t’ forget to set the array size at least equal to the string length plus 1.

The user accepts ‘Cities’ as the name of the file to be saved and clicks OK to dismiss the dialog, and the open file procedure opens the file in the ‘write’ mode. The allocate record procedure allocates a record in memory with a length of 18 bytes, and identifies it with RecNo[n], which is now 1.

City code is always 3 bytes plus 1 byte for end of string marker, the maximum length of Latitude and longitude is 6 bytes plus an additional byte for end of string. All data making up the record is stored as a continuous text string with the record length being the sum of each field plus an additional byte.

Three put field procedures take the global objects, City, Lat, and Long, and position them within the record. Arguments for put field are; record number, byte offset, and field length. Byte offset is expressed in bytes and the first position in a record is byte position zero. Field length is also expressed in bytes and is sized to handle the longest entry anticipated.

Figure 4 Output of our distance program

Procedures write record, free record, and close file complete the task of saving the record to disk. Now, because this is the first time this routine has been called, we set the value of flag to 1 or true. An alert is displayed informing the user that additional records added during this session will be saved without the GetFile dialog. Three set dialog item procedures clear the previously entered data, and position the text edit caret in the first text edit field ready for entry of the next record.

Assuming the user continues by entering data for the next record; when the Save It button is clicked, program flow progresses exactly as before. The difference is, when Store_Records is called this time, the counter n is incremented and the first if logic form now evaluates to true. The open file procedure opens the file ‘FileName’, and the get document length procedure returns the length in bytes of the file in the object ‘Position’. To avoid overwriting previously saved records, the file position procedure sets the file position according to the value of Position. From here on the same procedures are executed as before to save the record to disk.

Review_Records

Let’s say, for purposes of this tutorial, that you have entered all of the data and you wish to see if it is correct. By selecting View or Edit Records... from the Options menu, a non-modal dialog is displayed as shown in figure 2, and the Review_Records routine is called. This short routine opens the file ‘FileName’ in the read only mode. A for logic form provides a loop to be executed 10 times (NoRecs is a constant assigned the value of 10). The allocate record and read record procedures contained within the for loop are thusly executed 10 times to bring the entire file into memory. For safety sake the file is closed, and the value of the object n is set to zero.

When the Get Record button is clicked, the DoDialogEvent routine calls the Next_Record routine. As you might have guessed, when the Save Changes button is clicked, DoDialogEvent processes the request by calling the Save_Changes routine. The dialog is ultimately dismissed by clicking the window’s close box.

Next_Record

This routine is simply a series of get field and set dialog item procedures to display the contents of the records saved in the file ‘FileName’. To start at the beginning of the file, the object n is assigned the value of 1. Record Number is displayed by converting the object n to a byte type array named string with the procedure number to string. Note, the minimum dimension for a byte type array to handle number to string conversions is 13.

The Next_Record routine is called each time the user clicks the Get Record button. When the last record has been viewed, the assign procedure within the if logic form is executed to set the value of the object n to zero. This merely allows the continuous viewing of records by starting again at record number 1 when the last record has been displayed.

Figure 5 Our data base for distance calculation

Save_Changes

While viewing the records, changes may be made by entering the appropriate data in one or more of the text edit fields and clicking the Save Changes button. To no one’s surprise, the Save_Changes routine is called by the DoDialogEvent routine whenever the Save Changes button is clicked.

This routine simply opens the file ‘FileName’ in the write mode and sets the file position to overwrite the record to be changed. To do this, the procedure file position uses the argument (n-1)*18. Or in plain English, subtract 1 from the record number because the record pointer is left at the end of the record we wish to change. Now multiply by the record length (18), to set the file pointer to the correct position as calculated from the beginning of the file.

The actual writing of the record uses the same procedures as described previously. Two if logic forms are used to maintain correspondence with the actual record number, and if n=0 as is the case when the last record is the one to be edited, we simply assign the value of 10 to n. To make this a temporary measure, the object ‘flag’ is set to true, which is detected by the next if, and the value of n is once more zero. This only makes sense if you remember ‘n’ will always be something between 0 and 9 whenever this routine is called. So if n is equal to anything from 1 to 9, just write the record, else if n=0 change it to 10 temporarily. There must be an easier way.

Find_City

By selecting Compute Distance... from the Options menu, the dialog as shown in figure 4 is displayed. When the user enters the city codes for the origin and destination cities and clicks the Do It button, the Find_City routine is called by the Get_Input routine, and receives Origin and Destination as input arguments

The first thing this routine does is check to see if you are trying to fool it by entering the same city code for both the origin and destination cities. Normally an input like this should result in a distance of zero, but for some reason Apple’s SANE doesn’t like zero’s as operands for certain intrinsic functions. So, rather than having the Find_City routine complete all of its tasks, and then trap the error in the Calculate routine, I simply chose to display an alert informing the user of the problem.

Find_City opens the file ‘FileName’, reads the records into memory, and then compares the City field in the first record with the input argument Origin. If match=0 (are the same), two get field and string to number procedures extract and convert the data stored as Latitude and Longitude to numbers for the Origin City. When the origin city has been found, flag1 is set to true, and program execution continues looking for a match with the Destination city.

In this manner, the maximum number of times the records are searched for both the Origin and Destination cities is equal to the number of records in the file. If either flag1 or flag2 is not set to true, an alert informs the user that his choice is not in the file, and execution of this routine is terminated with a return procedure.

When both Origin and Destination cities have been found, Latitude and Longitude of the Origin and Destination cities are now passed to the Calculate routine as A,B,C,D respectively, as are the Origin and Destination city codes.

Calculate

If you haven’t fallen asleep by now, I’m sure you recall the data we stored as Latitude and Longitude represented degrees and minutes which were actually stored as byte arrays and later converted to real numbers by the Find_City routine. So, for example, the Latitude of LAX we entered was 3356 with the rightmost two characters representing the minutes portion in every case.

When the object A is received in this routine, and assuming LAX is the Origin city, it would appear as 3356.000 if we were to examine its value. To extract the minutes portion of this number we simply divide by 100 to move the decimal point two places to the left, and use the int & fract procedure to separate the integer and fractional portions so we can convert the fractional portion to decimal degrees. By dividing the fraction by 60 and multiplying by 100, and adding the fractional part now in decimal degrees to the integer we have a number we can almost work with.

This same series of manipulations is completed for objects B,C, and D, and now because SANE utilizes radians when working with sin, cos, and acos, we need to do another conversion. By multiplying each object A,B,C,D by (pi/180) we are finally ready to do the calculation to see how far it is between our Origin and Destination cities, however the answer wont make any sense until we convert the result ‘Dist’ to Nautical Miles. The distance is rounded off to the nearest whole number, converted to a string, and a series of draw string procedures displays the results as shown in figure 3.

Odds & Ends

If all of this seems like the long way around to arrive at the shortest distance between two points, you are probably correct. In this example program with only 10 cities we could have as easily entered Latitudes and Longitudes in a form that would not require conversion. However, when considering there are over 6900 airports in the world, each with its own identifier and Latitude and Longitude, you can perhaps appreciate the simplicity of using whole numbers to represent degrees and minutes rather than complex numbers more easily assimilated by a computer.

One routine we didn’t talk about this time is DoCloseBox. This routine is fairly straightforward, and performs the chores of disposing of the various windows and non modal dialogs used by the program. The only thing worth mentioning is my solution to avoid the possibility of opening the same window twice. In the DoOptions routine you will see that I have inserted a disable menu item procedure which globally disables the Options menu whenever a routine using a window is called. While this isn’t the most elegant way of avoiding the embarrassment of not being able to close a window, it works. An enable menu item procedure in the DoCloseBox routine is executed to restore the Options menu after the current window is closed.

That about does it for this time. I hope what you have read here is helpful in learning Visual Interactive Programming. If you would like to see other V.I.P. stuff, write to MacTutor! In the meantime have fun, after all that’s what it’s all about.

byte
 AboutFlag
 AboutWindow
 City[4]
 EditDialog
 EditWindow
 FileName[7]={‘C’,’i’,’t’,’i’,’e’,’s’,’\0'}
 InputDialog
 InputWindow
 Lat[7]
 Long[7]
 Menu[3]
 Quit
 RecordDialog
 RecordWindow
 WhichWindow
 Window
 flag
 go
 n

integer
 RecNo[10]

rectangle
 r

constants
 NoRecs = 10
 pi = 3.14159265

main
GC_Dist program for MacTutor™
by Bill Luckie  © 1987

Visual Interactive Programming
V.I.P. by Dominique Lienart, published by Mainstay.
===================================
DoSetup
while (! Quit)
 DoSelect
exit
===================================


Calculate (A,B,C,D,Origin,Destination)

--> real A
--> real B
--> real C
--> real D
--> byte Origin[4]
--> byte Destination[4]

byte
 S2[13]

integer
 Distance

real
 Dist
 fraction
 integer

rectangle
 r

assign (A / 100,A)
int & fract (A,integer,fraction)
assign (fraction / 60 * 100,fraction)
assign (integer + fraction,A)
assign (B / 100,B)
int & fract (B,integer,fraction)
assign (fraction / 60 * 100,fraction)
assign (integer + fraction,B)
assign (C / 100,C)
int & fract (C,integer,fraction)
assign (fraction / 60 * 100,fraction)
assign (integer + fraction,C)
assign (D / 100,D)
int & fract (D,integer,fraction)
assign (fraction / 60 * 100,fraction)
assign (integer + fraction,D)
assign (A * (pi/180),A)
assign (B * (pi/180),B)
assign (C * (pi/180),C)
assign (D * (pi/180),D)
assign (60*acos(sin(A)*sin(C)+cos(A)*cos(C)*cos(D-B)),Dist)
assign (Dist * (1/pi * 180),Dist)
int & fract (Dist,integer,fraction)
if (fraction   .5)
 assign (integer + 1,Distance)
else 
 assign (integer,Distance)
number to string (“@i”,Distance,S2)
activate window (Window)
set text font (0)
move to (50,18)
draw string (“The distance from “,0)
draw string (Origin,0)
draw string (“ to “,0)
draw string (Destination,0)
draw string (“ is “,0)
draw string (S2,0)
draw string (“ Nautical miles.”,0)
===================================
DoAbout

byte
 ID
 go
 message
 type

point
 location

rectangle
 Portrect
 Windowrect

assign (0,go)
set rect (60,60,120,450,Windowrect)
set rect (0,0,120,450,Portrect)
new window (4,0,1,Windowrect,Portrect,””,Window)
set text font (0)
move to (15,85)
draw string (“GC_Dist program for MacTutor™”,0)
move to (30,145)
draw string (“ by Bill Luckie.”,0)
move to (45,168)
draw string (“© 1987”,0)
if (AboutFlag)
 while (! go)
 get next event (type,location,message,ID)
 if (type = 3)
 assign (1,go)
 else 
 
else 
 wait (90)
kill window (Window)
assign (1,AboutFlag)
assign (0,Window)
===================================
DoCloseBox

get window (WhichWindow)
if (WhichWindow = AboutWindow)
 kill window (AboutWindow)
 assign (0,AboutWindow)
else 
 if (WhichWindow = InputWindow)
 kill window (Window)
 assign (0,Window)
 kill dialog (InputDialog)
 assign (0,InputWindow)
 assign (0,InputDialog)
 else 
 if (WhichWindow = EditWindow)
 kill dialog (EditDialog)
 assign (0,EditWindow)
 assign (0,EditDialog)
 else 
 
enable menu item (Menu[3],0)
===================================
DoDialogEvent (Dialog,item)

--> byte Dialog
--> byte item

if (Dialog = RecordDialog)
 switch (item,1,2)
 case 1
 Get_Record
 Store_Records
 case 2
 kill dialog (RecordDialog)
 assign (0,RecordDialog)
 default 
 
else 
 if (Dialog = InputDialog & item = 1)
 Get_Input
 else 
 if (Dialog = EditDialog)
 switch (item,1,2)
 case 1
 Next_Record
 case 2
 Save_Changes
 default 
 
 else 
===================================
DoEdit (item)

--> byte item

switch (item,3,4,5,6)
case 1
 cut text
case 2
 copy text
case 3
 paste text
case 4
 clear text
default 
===================================
DoFile (item)

--> byte item

byte
 result

switch (item,1,2,4)
case 1
 set up page
case 2
 if (AboutWindow)
 print text (AboutWindow)
 else 
 alert (1,”There is no window to print from.”,result)
case 3
 assign (1,Quit)
default 
===================================
DoMenuSelect (menu,item)

--> byte menu
--> byte item

switch (menu,Menu[1],Menu[2],Menu[3])
case 1
 DoFile (item)
case 2
 DoEdit (item)
case 3
 DoOptions (item)
default 
===================================
DoOptions (item)

--> byte item

switch (item,1,2,3,5)
case 1
 Record_Dialog
case 2
 disable menu item (Menu[3],0)
 Edit_Dialog
case 3
 disable menu item (Menu[3],0)
 Input_Dialog
case 4
 disable menu item (Menu[3],0)
 Gee_Whiz
default 
===================================
DoSelect

byte
 EventID
 EventMessage
 EventType

point
 MouseLocation

get next event (EventType,MouseLocation,EventMessage,EventID)
switch (EventType,1,4,5)
case 1
 if (EventMessage=0 & EventID=1)
 DoAbout
 else 
 DoMenuSelect (EventMessage,EventID)
case 2
 DoCloseBox
case 3
 DoDialogEvent (EventMessage,EventID)
default 
===================================
DoSetup

new menu (“File”,Menu[1])
append menu item (Menu[1],”Page Setup...;Print...;(-;Quit/Q”)
new menu (“Edit”,Menu[2])
append menu item (Menu[2],”(Undo/Z;(-;Cut/X;Copy/C;Paste/V;Clear”)
new menu (“Options”,Menu[3])
append menu item (Menu[3],”Create new Records...;View or Edit Records...;Compute 
Distance...;(-;Gee Whiz Stuff...”)
DoAbout
===================================
Edit_Dialog

rectangle
 r

set rect (100,106,250,406,r)
new dialog (r,”Edit Records”,EditDialog)
set rect (111,23,144,116,r)
append dialog item (EditDialog,1,r,”Get Record”)
set rect (111,179,144,280,r)
append dialog item (EditDialog,1,r,”Save Changes”)
set rect (3,72,19,228,r)
append dialog item (EditDialog,4,r,”Review & Edit Records.”)
set rect (27,50,43,150,r)
append dialog item (EditDialog,4,r,”City Code:”)
set rect (47,50,63,150,r)
append dialog item (EditDialog,4,r,”Latitude:”)
set rect (67,50,83,150,r)
append dialog item (EditDialog,4,r,”Longitude:”)
set rect (87,50,103,156,r)
append dialog item (EditDialog,4,r,”Record No.:”)
set rect (29,190,45,217,r)
append dialog item (EditDialog,5,r,””)
set rect (50,190,66,240,r)
append dialog item (EditDialog,5,r,””)
set rect (71,190,87,240,r)
append dialog item (EditDialog,5,r,””)
set rect (88,138,104,158,r)
append dialog item (EditDialog,5,r,””)
open dialog (EditDialog,EditWindow)
Review_Records
===================================
Find_City (Origin,Destination)

--> byte Origin[4]
--> byte Destination[4]

byte
 f
 flag1
 flag2
 match
 n
 result

integer
 RecNo[10]

real
 A
 B
 C
 D

compare string (Origin,Destination,match)
if (match = 0)
 alert (1,”The Origin and Destination cities are the same.”,result)
 return
else 
 
assign (0,flag1)
assign (0,flag2)
open file (FileName,1,”TEXT”,f)
for (n,1,NoRecs,1)
 allocate record (18,RecNo[n])
 read record (f,RecNo[n])
close file (f)
for (n,1,NoRecs,1)
 get field (n,0,4,City)
 upper case (City)
 compare string (City,Origin ,match)
 if (match = 0)
 get field (n,4,7,Lat)
 string to number (3,Lat,A)
 get field (n,11,7,Long)
 string to number (3,Long,B)
 assign (1,flag1)
 else 
 
 compare string (City,Destination,match)
 if (match = 0)
 get field (n,4,7,Lat)
 string to number (3,Lat,C)
 get field (n,11,7,Long)
 string to number (3,Long,D)
 assign (1,flag2)
 else 
 
if (! flag1)
 alert (1,”Sorry, Origin city code not in file.”,result)
 return
else 
 if (! flag2)
 alert (1,”Sorry, Destination city code not in file.”,result)
 return
 else 

Calculate (A,B,C,D,Origin,Destination)
===================================
Gee_Whiz

byte
 AboutFile

rectangle
 PortRect
 WindowRect

set rect (50,40,312,472,WindowRect)
set rect (0,0,1000,432,PortRect)
new window (7,1,1,WindowRect,PortRect,”Gee Whiz Stuff”,AboutWindow)
open file (“Gee_Whiz”,1,”TEXT”,AboutFile)
load text (AboutFile,AboutWindow)
close file (AboutFile)
===================================
Get_Input

byte
 Destination[4]
 Origin[4]
 state

clear window (Window)
get dialog item (InputDialog,4,state,Origin)
upper case (Origin)
get dialog item (InputDialog,5,state,Destination)
upper case (Destination)
Find_City (Origin,Destination)
===================================
Get_Record

byte
 state

get dialog item (RecordDialog,7,state,City)
upper case (City)
get dialog item (RecordDialog,8,state,Lat)
get dialog item (RecordDialog,9,state,Long)
===================================
Input_Dialog

rectangle
 r
 r1

set rect (182,61,326,451,r)
new dialog (r,”Select cities”,InputDialog)
set rect (106,164,137,227,r)
append dialog item (InputDialog,1,r,”Do it”)
set rect (31,104,47,204,r)
append dialog item (InputDialog,4,r,”Origin:”)
set rect (62,104,78,204,r)
append dialog item (InputDialog,4,r,”Destination:”)
set rect (34,220,50,245,r)
append dialog item (InputDialog,5,r,””)
set rect (60,220,76,245,r)
append dialog item (InputDialog,5,r,””)
set rect (3,49,26,342,r)
append dialog item (InputDialog,4,r,”Enter city codes for Origin & Destination.”)
set rect (52,68,152,444,r)
set rect (0,0,155,447,r1)
new window (4,0,1,r,r1,””,Window)
open dialog (InputDialog,InputWindow)
===================================
Next_Record

byte
 result
 string[13]

assign (n + 1,n)
get field (RecNo[n],0,4,City)
set dialog item (EditDialog,8,9,City)
get field (RecNo[n],4,7,Lat)
set dialog item (EditDialog,9,9,Lat)
get field (RecNo[n],11,7,Long)
set dialog item (EditDialog,10,9,Long)
number to string (“@b”,n,string)
set dialog item (EditDialog,11,9,string)
if (n = NoRecs)
 assign (0,n)
else 
===================================
Record_Dialog

rectangle
 r

set rect (100,154,251,359,r)
new dialog (r,””,RecordDialog)
set rect (115,5,147,85,r)
append dialog item (RecordDialog,1,r,”Save It”)
set rect (115,119,147,199,r)
append dialog item (RecordDialog,1,r,”Quit”)
set rect (4,38,22,176,r)
append dialog item (RecordDialog,4,r,”Enter new records”)
set rect (30,6,46,106,r)
append dialog item (RecordDialog,4,r,”City Code:”)
set rect (60,6,76,106,r)
append dialog item (RecordDialog,4,r,”Latitude:”)
set rect (90,6,105,106,r)
append dialog item (RecordDialog,4,r,”Longitude:”)
set rect (30,105,46,140,r)
append dialog item (RecordDialog,5,r,””)
set rect (60,105,76,162,r)
append dialog item (RecordDialog,5,r,””)
set rect (90,105,106,162,r)
append dialog item (RecordDialog,5,r,””)
open dialog (RecordDialog,RecordWindow)
===================================
Review_Records

byte
 f

integer
 result
open file (FileName,1,”TEXT”,f)
for (n,1,NoRecs,1)
 allocate record (18,RecNo[n])
 read record (f,RecNo[n])
close file (f)
assign (0,n)
===================================
Save_Changes
byte
 f
 state

integer
 result

assign (0,flag)
open file (FileName,2,”TEXT”,f)
if (n = 0)
 assign (10,n)
 assign (1,flag)
else 
 
file position (f,(n-1) * 18,0,result)
get dialog item (EditDialog,8,state,City)
get dialog item (EditDialog,9,state,Lat)
get dialog item (EditDialog,10,state,Long)
allocate record (18,RecNo[n])
put field (RecNo[n],0,4,City)
put field (RecNo[n],4,7,Lat)
put field (RecNo[n],11,7,Long)
write record (f,RecNo[n])
close file (f)
if (flag)
 assign (0,n)
else 
===================================
Store_Records
byte
 f
 ok
 result

integer
 Position
 RecNo[10]
 status

assign (n + 1,n)
if (flag)
 open file (FileName,2,”TEXT”,f)
 get document length (FileName,Position)
 file position (f,Position,0,status)
 allocate record (18,RecNo[n])
 put field (RecNo[n],0,4,City)
 put field (RecNo[n],4,7,Lat)
 put field (RecNo[n],11,7,Long)
 write record (f,RecNo[n])
 free record (RecNo[n])
 close file (f)
else 
 get document name (1,”Save file as ‘Cities’”,”TEXT”,ok,FileName)
 if (ok)
 open file (FileName,2,”TEXT”,f)
 allocate record (18,RecNo[n])
 put field (RecNo[n],0,4,City)
 put field (RecNo[n],4,7,Lat)
 put field (RecNo[n],11,7,Long)
 write record (f,RecNo[n])
 free record (RecNo[n])
 close file (f)
 assign (1,flag)
 alert (1,”Additional records added during this session will be saved 
without the GetFile dialog.” ,result)
 else 
 
set dialog item (RecordDialog,7,1,””)
set dialog item (RecordDialog,8,9,””)
set dialog item (RecordDialog,9,9,””)
 
AAPL
$104.83
Apple Inc.
+1.84
MSFT
$45.02
Microsoft Corpora
+0.64
GOOG
$543.98
Google Inc.
+11.27

MacTech Search:
Community Search:

Software Updates via MacUpdate

Delicious Library 3.3.2 - Import, browse...
Delicious Library allows you to import, browse, and share all your books, movies, music, and video games with Delicious Library. Run your very own library from your home or office using our... Read more
Art Text 2.4.8 - Create high quality hea...
Art Text is an OS X application for creating high quality textual graphics, headings, logos, icons, Web site elements, and buttons. Thanks to multi-layer support, creating complex graphics is no... Read more
Live Interior 3D Pro 2.9.6 - Powerful an...
Live Interior 3D Pro is a powerful yet very intuitive interior designing application. View Video Tutorials It has every feature of Live Interior 3D Standard, plus some exclusive ones: Create multi... Read more
The Hit List 1.1.7 - Advanced reminder a...
The Hit List manages the daily chaos of your modern life. It's easy to learn - it's as easy as making lists. And it's powerful enough to let you plan, then forget, then act when the time is right.... Read more
jAlbum Pro 12.2.4 - Organize your digita...
jAlbum Pro has all the features you love in jAlbum, but comes with a commercial license. With jAlbum, you can create gorgeous custom photo galleries for the Web without writing a line of code!... Read more
jAlbum 12.2.4 - Create custom photo gall...
With jAlbum, you can create gorgeous custom photo galleries for the Web without writing a line of code! Beginner-friendly, with pro results Simply drag and drop photos into groups, choose a design... Read more
ExpanDrive 4.1.7 - Access remote files o...
ExpanDrive builds cloud storage in every application, acts just like a USB drive plugged into your Mac. With ExpanDrive, you can securely access any remote file server directly from the Finder or... Read more
OmniOutliner Pro 4.1.3 - Pro version of...
OmniOutliner Pro is a flexible program for creating, collecting, and organizing information. Give your creativity a kick start by using an application that's actually designed to help you think. It'... Read more
Evernote 5.6.2 - Create searchable notes...
Evernote allows you to easily capture information in any environment using whatever device or platform you find most convenient, and makes this information accessible and searchable at anytime, from... Read more
OmniOutliner 4.1.3 - Organize your ideas...
OmniOutliner is a flexible program for creating, collecting, and organizing information. Give your creativity a kick start by using an application that's actually designed to help you think. It's... Read more

Latest Forum Discussions

See All

A Few Days Left (Games)
A Few Days Left 1.01 Device: iOS Universal Category: Games Price: $3.99, Version: 1.01 (iTunes) Description: Screenshots are in compliance to App Store's 4+ age rating! Please see App Preview for real game play! **Important: Make... | Read more »
Toca Boo (Education)
Toca Boo 1.0.2 Device: iOS Universal Category: Education Price: $2.99, Version: 1.0.2 (iTunes) Description: BOO! Did I scare you!? My name is Bonnie and my family loves to spook! Do you want to scare them back? Follow me and I'll... | Read more »
Intuon (Games)
Intuon 1.1 Device: iOS Universal Category: Games Price: $.99, Version: 1.1 (iTunes) Description: Join the battle with your intuition in a new hardcore game Intuon! How well do you trust your intuition? Can you find a needle in a... | Read more »
Ravenous Rampage (Games)
Ravenous Rampage 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: | Read more »
Partia 2 (Games)
Partia 2 1.0.1 Device: iOS Universal Category: Games Price: $5.99, Version: 1.0.1 (iTunes) Description: Partia 2 is a SRPG (Strategy Role-playing) video game inspired by Fire Emblem and Tear Ring Saga series. In a high fantasy... | Read more »
Puzzle to the Center of the Earth Review
Puzzle to the Center of the Earth Review By Campbell Bird on October 23rd, 2014 Our Rating: :: SPELUNKING PUZZLESUniversal App - Designed for iPhone and iPad Do some puzzles to make some platforms in this smart and fun free-to-play... | Read more »
Sleep Attack TD Review
Sleep Attack TD Review By Jennifer Allen on October 23rd, 2014 Our Rating: :: A TRUE TWISTUniversal App - Designed for iPhone and iPad Sleep Attack TD is a tower defense game with a difference – you can rotate the layout – and it’s... | Read more »
Mecanic (Education)
Mecanic 1.0 Device: iOS Universal Category: Education Price: $1.99, Version: 1.0 (iTunes) Description: Plates, screws, wheels ... Everything you need to achieve whatever you want... MECHANICWith 'MECANIC' kids will have fun... | Read more »
Earn Your Master Camper Badge in Camp Po...
Earn Your Master Camper Badge in Camp Pokemon Posted by Jessica Fisher on October 23rd, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Garruk Gets His Revenge in a New Magic 2...
Garruk Gets His Revenge in a New Magic 2015 Expansion, Coming This November Posted by Jessica Fisher on October 23rd, 2014 [ permalink ] | Read more »

Price Scanner via MacPrices.net

Save up to $125 on Retina MacBook Pros
B&H Photo has the new 2014 13″ and 15″ Retina MacBook Pros on sale for up to $125 off MSRP. Shipping is free, and B&H charges NY sales tax only. They’ll also include free copies of Parallels... Read more
Apple refurbished Time Capsules available sta...
The Apple Store has certified refurbished Time Capsules available for up to $60 off MSRP. Apple’s one-year warranty is included with each Time Capsule, and shipping is free: - 2TB Time Capsule: $255... Read more
Textilus New Word, Notes and PDF Processor fo...
Textilus is new word-crunching, notes, and PDF processor designed exclusively for the iPad. I haven’t had time to thoroughly check it out yet, but it looks great and early reviews are positive.... Read more
WD My Passport Pro Bus-Powered Thunderbolt RA...
WD’s My Passport Pro RAID solution is powered by an integrated Thunderbolt cable for true portability and speeds as high as 233 MB/s. HighlightsOverviewSpecifications Transfer, Back Up And Edit In... Read more
Save with Best Buy’s College Student Deals
Take an additional $50 off all MacBooks and iMacs at Best Buy Online with their College Students Deals Savings, valid through November 1st. Anyone with a valid .EDU email address can take advantage... Read more
iPad Air 2 & iPad mini 3 Best Tablets Yet...
The new iPads turned out to be pretty much everything I’d been hoping for and more than I’d expected.”More” particularly in terms of a drinking-from-a-firehose choice of models and configurations,... Read more
Drafts 4 Reinvents iOS Productivity App
N Richland Hills, Texas based Agile Tortoise has announced the release of Drafts 4 for iPhone and iPad. Drafts is a quick capture note taking app with flexible output actions. Drafts 4 scales from... Read more
AT&T accepting preorders for new iPads fo...
AT&T Wireless is accepting preorders for the new iPad Air 2 and iPad mini 3, cellular models, for $100 off MSRP with a 2-year service agreement: - 16GB iPad Air 2 WiFi + Cellular: $529.99 - 64GB... Read more
Apple offering refurbished Mac Pros for up to...
The Apple Store is offering Apple Certified Refurbished 2013 Mac Pros for up to $600 off the cost of new models. An Apple one-year warranty is included with each Mac Pro, and shipping is free. The... Read more
Select MacBook Airs $100 off MSRP, free shipp...
B&H Photo has 2014 a couple of MacBook Airs on sale for $100 off MSRP. Shipping is free, and B&H charges NY sales tax only. They also include free copies of Parallels Desktop and LoJack for... Read more

Jobs Board

*Apple* Solutions Consultant - Apple Inc. (U...
…important role that the ASC serves is that of providing an excellent Apple Customer Experience. Responsibilities include: * Promoting Apple products and solutions Read more
Senior Event Manager, *Apple* Retail Market...
…This senior level position is responsible for leading and imagining the Apple Retail Team's global event strategy. Delivering an overarching brand story; in-store, Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
Project Manager / Business Analyst, WW *Appl...
…a senior project manager / business analyst to work within our Worldwide Apple Fulfillment Operations and the Business Process Re-engineering team. This role will work Read more
*Apple* Retail - Multiple Positions (US) - A...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.