Wincom and Internet Explorer example

This section provides a Wincom and Internet Explorer example.

This example executes Internet Explorer on a defined URL with the address bar masked.
DEFINE ieapp INTEGER
DEFINE ienav INTEGER
MAIN
  DEFINE result INTEGER
--initialization of global variables
  LET ieapp = -1
  LET ienav = -1
--first, we must create an Instance of Internet Explorer application
  CALL ui.Interface.frontCall("WinCOM", "CreateInstance",
   ["InternetExplorer.Application"], [ieapp])
  CALL CheckError(ieapp, __LINE__)
--then, specifying the URL you want to load
  CALL call ui.interface.frontCall("WinCOM", "CallMethod",
   [ie_app, "Navigate", "www.4js.com"], [ienav])
  CALL CheckError(ienav, __LINE__)
--then, masking the address bar
  CALL ui.interface.frontCall("WinCOM", "SetProperty",
   [ieapp, "AddressBar", false], [result])
  CALL CheckError(result, __LINE__)
--then, setting it to visible
  CALL ui.interface.frontCall("WinCOM", "SetProperty", [ieapp, "Visible", true],
   [result])
  CALL CheckError(result, __LINE__)
--then Free the memory on the client side
  CALL freeMemory()
END MAIN

FUNCTION freeMemory()
  DEFINE res INTEGER
  IF ienav != -1 THEN
    CALL ui.Interface.frontCall("WinCOM","ReleaseInstance", [ienav], [res] )
  END IF
  IF ieapp != -1 THEN
    CALL ui.Interface.frontCall("WinCOM","ReleaseInstance", [ieapp], [res] )
  END IF
END FUNCTION

FUNCTION checkError(res, lin)
  DEFINE res INTEGER
  DEFINE lin INTEGER
  DEFINE mess STRING
  IF res = -1 THEN
    DISPLAY "COM Error for call at line:", lin
    CALL ui.Interface.frontCall("WinCOM","GetError",[],[mess])
    DISPLAY mess
--let's release the memory on the GDC side
    CALL freeMemory()
    DISPLAY "Exit with COM Error."
    EXIT PROGRAM (-1)
  END IF
END FUNCTION