startmacro/msgid=main s:gfile

aux ,, DAT
res details "OFF"

pipe init

plot/id=plot world

pipe run
pipe wait
pipe off


endmacro

procedure processMessage

if ^msg.name eqs "MAPVIEW" then
  res reg.plot.view ^msg.data.view
elseif ^msg.name eqs "MAPDETAILS" then
  if ^msg.data.details neqs details then
    sedit msg.data.details details UPCASE
    if ^details eqs "ON" then
       message send plot ,, openfile ,, "MAP2"
    else
       message send plot ,, closefile ,, "MAP2"
    endif
  endif
elseif ^msg.name eqs "GEORESULT" then
  res feat "F^{msg.data.index}"
  
  if ^msg.data.show eq 1 then
    if ^{feat} nrexists then
      feature ,, ^feat {NAME=^feat, TYPE=0x81, COLOR=RED &
                  ENABLE=0x03, LABEL="feature: ^feat", &
                  X=^msg.data.lat, Y=^msg.data.lon, &
		  MAJOR=^msg.data.maj, MINOR=^msg.data.min, &
		  TILT=^msg.data.tilt} plot
    else
      set reg.plot.addFeature ^feat
    endif
  else
    if ^{feat} rexists then
      set ^{feat}.delete 
      rem ^feat
    endif  
  endif
elseif ^msg.name eqs "EXIT" then
  stop
endif  

return
