/* GenesisOnline.yam - Go online in Genesis
 * Based on MiamiOnline 1.0 (1.10.98) by M.Beck
 * 1.00 - 08.11.00	First Public version
 * $VER: GenesisOnline.yam 1.00 (8.11.00) © H. van der Ree <hivdree@uwnet.nl>
 *
 * Don't forget to change the interface into the one you use!
 */

OPTIONS RESULTS

genesispath = "AmiTCP:Genesis"  /* Change this path if required */
genesisport = "GENESIS"

/* Change this to the interface you use */
interface = "Internet"

/* Make sure the necessary libraries are available */
IF ~SHOW('L', 'rexxdossupport.library') THEN
  CALL ADDLIB('rexxdossupport.library', 0, -30)

action = GETVAR(YAMSTARTED, 'GLOBAL')
IF action = "YES" THEN DO
  CALL DELETEVAR(YAMSTARTED, 'GLOBAL')
  EXIT 0
END

RCN = 0
ADDRESS COMMAND
'c:pubscrname >ENV:TMPSCR'
tmppubscreen = GETVAR(TMPSCR, 'GLOBAL')
CALL DELETEVAR(TMPSCR, 'GLOBAL')

IF ~SHOW('P', genesisport) THEN DO
  'c:screentofront "Workbench"'
  'c:wbstarter' genesispath
  'WaitForPort' genesisport
  CALL DELAY(100)
END

ADDRESS VALUE genesisport
ISONLINE interface
IF RC = 0 THEN DO
  CALL SETVAR(YAMSTART, "YES", 'GLOBAL')
  ONLINE interface
  DO UNTIL RCN = 1
    ISONLINE interface		/* 0 = OFFLINE, 1 = ONLINE, 2 = DAILING */
    RCN = RC
    IF RCN = 0 THEN DO
      CALL DELETEVAR(YAMSTART, 'GLOBAL')
      ADDRESS COMMAND
      'c:screentofront ' tmppubscreen
      EXIT 5
    END
    IF RCN ~= 1 THEN DELAY(100)
  END
  CALL DELAY(100)		/* Wait 2 secs before going to YAM! */
END

ADDRESS COMMAND
'c:screentofront' tmppubscreen

EXIT 0
