REM REM Demonstration of using the WLD: device interface REM from OPL to extract sunrise/sunset information REM for a city. REM REM This code is public-domain. REM REM Ajai Khattri (ajai@nwt.com) REM PROC main: LOCAL h% LOCAL state% LOCAL name$(21) LOCAL data%(44) LOCAL ptr% LOCAL hour%, min% REM open I/O channel to WLD: IOOPEN(h%, "WLD:", -1) REM Note: search string can be any case dINIT "Search for city" dEDIT name$, "City:", 21 IF DIALOG = 0 STOP ELSEIF name$ = "" STOP ENDIF REM ptr% points to start of search name ptr% = ADDR(name$) + 1 name$ = name$ + CHR$(0) REM Added to zero terminate string REM 10 is the 'find city' function IOW(h%, 10, #ptr%, data%()) REM 22 is the 'get city data' function IOW(h%, 22, data%(), #0) REM Calculate sunrise/sunset times state% = 1 DO REM 24 is the 'calculate data' function IOW(h%, 24, state%, data%()) UNTIL state%=0 REM Display results to user dINIT "Times for " + UPPER$(name$) hour% = data%(2) / 60 min% = data%(2) - (hour% * 60) dTEXT "Sunrise:",GEN$(hour%, 2)+":"+ GEN$(min%, 2) hour% = data%(3) / 60 REM Changed from 43 to 3 - Don't know why! min% = data%(3) - (hour% * 60) dTEXT "Sunset:", GEN$(hour%, 2) + ":" + GEN$(min%,2) IF DIALOG=0 STOP ENDIF ENDP