ReadLocationYou can use the
ReadLocationprocedure 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.
ReadLocationprocedure reads the stored geographic location and time zone of the Macintosh computer from extended parameter RAM and returns it in the
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
Fractvalues, giving accuracy to within one foot. For example,
a Fractvalue 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
Fractvalues first to the
Fixeddata type, then to the
LongIntdata type. You can use the Mathematical and Logical Utilities routines
Fix2Longto accomplish this task.
The DST value is a signed byte value that you can use to specify the offset for the
hourfield--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
gmtDeltafield is a 3-byte value contained in a long word, so you must take care to get it properly.
SPECIAL CONSIDERATIONSAlthough the
ReadLocationprocedure does not move or purge memory, you should not call it at interrupt time.
SEE ALSOFor more information on the geographic location record, see page 4-29. For an example of how to use the
ReadLocationprocedure 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
For more information on the
Fractdata type and the conversion routines
Fix2Long, see the chapter "Mathematical and Logical Utilities" in this book.