Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

Previous Book Contents Book Index Next

Inside Macintosh: Operating System Utilities /
Chapter 4 - Date, Time, and Measurement Utilities / Date, Time, and Measurement Utilities Reference
Routines / Reading and Writing Location Data


You can use the ReadLocation procedure to get information about a geographic location or time zone.

PROCEDURE ReadLocation (VAR loc: MachineLocation);
On return, the fields of the geographic location record containing the geographic location and the time-zone information.
The ReadLocation procedure reads the stored geographic location and time zone of the Macintosh computer from extended parameter RAM and returns it in the loc parameter.

You can get values for the latitude, longitude, daylight savings time (DST), or Greenwich mean time (GMT). If the geographic location record has never been set, all fields contain 0.

The latitude and longitude are stored as Fract values, giving accuracy to within one foot. For example, a Fract value of 1.0 equals 90 degrees; -1.0 equals -90 degrees; and -2.0 equals -180 degrees.

To convert these values to a degrees format, you need to convert the Fract values first to the Fixed data type, then to the LongInt data type. You can use the Mathematical and Logical Utilities routines Fract2Fix and Fix2Long to accomplish this task.

The DST value is a signed byte value that you can use to specify the offset for the hour field--whether to add one hour, subtract one hour, or make no change at all.

The GMT value is in seconds east of GMT. For example, San Francisco is at -28,800 seconds (8 hours * 3,600 seconds per hour) east of GMT. The gmtDelta field is a 3-byte value contained in a long word, so you must take care to get it properly.

Although the ReadLocation procedure does not move or purge memory, you should not call it at interrupt time.

For more information on the geographic location record, see page 4-29. For an example of how to use the ReadLocation procedure to get latitude and longitude, see Listing 4-8 on page 4-19. Listing 4-9 on page 4-20 shows an application-defined procedure for obtaining the value of gmtDelta.

For more information on the Fract data type and the conversion routines Long2Fix, Fix2Fract, Fract2Fix, and Fix2Long, see the chapter "Mathematical and Logical Utilities" in this book.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996

Get information on Apple products.
Visit the Apple Store online or at retail locations.

Copyright © 2004 Apple Computer, Inc.
All rights reserved. | Terms of use | Privacy Notice