FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

SYSTEM

Know the geographical location of the user


Here's a demo:

_machineLocation = 12
_myGmtDelta = 8
'-------------------------------------------------
LOCAL FN ReadLocation(locRecAddr&)
'Call as follows:
' FN ReadLocation(@myLocn)
'where myLocn is a 12-byte record
  ` MOVE.L ^locRecAddr&,A0
  ` MOVE.L #$000C00E4,D0
  ` DC.W $A051
END FN
'-------------------------------------------------
LOCAL FN GetLocationInfo(latAddr&, longAddr&, zoneAddr&, dstAddr&)
'Call as follows:
' FN GetLocationInfo(@degLat!, @degLong!, @zoneSec&, @dstFlag)
'
'Reads location/zone info from extended p-RAM.
' -- degLat! and degLong! are returned in degrees.
' Negative latitude means "south"; negative longitude means "west"
' -- The time zone is expressed as a number of seconds which
' should be subtracted from local Mac time to get Universal Time.
' Divide this by 3600 to get number of hours east of Greenwich.
' -- dstFlag will be nonzero if Daylight Savings Time is in effect.
  DIM myLocn.machineLocation
  FN ReadLocation(@myLocn)
  degLat! = 360.0 * myLocn.latitude& / (2^32)
  degLong! = 360.0 * myLocn.longitude& / (2^32)
'Zone is actually 3 bytes, which must be sign-extended:
  zoneSec& = myLocn.myGmtDelta& AND &00FFFFFF
  IF zoneSec& AND &00800000 THEN zoneSec& = zoneSec& OR &FF000000
  dstFlag = PEEK(@myLocn + _dlsDelta)
  POKE LONG latAddr&, PEEK LONG(@degLat!)
  POKE LONG longAddr&, PEEK LONG(@degLong!)
  POKE LONG zoneAddr&, zoneSec&
  POKE WORD dstAddr&, dstFlag
END FN

FN GetLocationInfo(@degLat!, @degLong!, @zoneSec&, @dstFlag)
CLS
PRINT degLat!, degLong!
PRINT zoneSec&
PRINT dstFlag
INPUT x$
'---------------------------------

Rick