*****************************************
      * CobolScript program name: dns.cbl
      * This web-based program provides an example 
      * of GETHOSTBYNAME usage, of array usage, 
      * of storing html in gldi's, and of inline
      * PERFORM VARYINGs. 
      *
      * Copyright 2000 Deskware, Inc.
      *****************************************
      * Include the TCP/IP variable copybook.
       COPY `tcpip.cpy`.

       1 content_length   PIC 9(05).

       1 web_header_html.
        5 `Content-type: text/html`.
        5 ` `.
        5 ``.
        5 `
`. 5 `Sample CobolScript DNS Application`. 5 `

`. 5 `Enter a Fully Qualified Domain Name or an IP address and then click on the Resolve button.`. 5 `
`. 5 ``. 5 ``. 5 `
`. 5 `
`. 1 web_footer_html. 5 ``. MAIN. GETENV USING `CONTENT_LENGTH` content_length. IF content_length > 0 ACCEPT DATA FROM WEBPAGE END-IF. IF host_name = SPACES MOVE `www.cornell.edu` TO host_name END-IF. * Populate TCP/IP structure that is defined in included copybook. GETHOSTBYNAME USING host_name. DISPLAYLF web_header_html. PERFORM DISPLAY-TCPIP-INFO. DISPLAYLF web_footer_html. GOBACK. DISPLAY-TCPIP-INFO. 1 counter PIC Z9. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. * Display all hostent-address elements from inside inline PERFORM loop PERFORM VARYING counter FROM 1 BY 1 UNTIL counter > 8 DISPLAY `` DISPLAY `` DISPLAY `` DISPLAY `` END-PERFORM. DISPLAY ``. DISPLAY ``. DISPLAY ``. DISPLAY ``. * Display all hostent-alias elements from inside inline PERFORM loop PERFORM VARYING counter FROM 1 BY 1 UNTIL counter > 8 DISPLAY `` DISPLAY `` DISPLAY `` DISPLAY `` END-PERFORM. DISPLAY `
host_name:` & host_name & `
TCPIP-RETURN-CODE: ` & TCPIP-RETURN-CODE & `
TCPIP-RETURN-MESSAGE: ` & TCPIP-RETURN-MESSAGE & ` 
TCPIP-HOSTENT-HOSTNAME: ` & TCPIP-HOSTENT-HOSTNAME & ` 
TCPIP-HOSTENT-ADDRESS-TYPE: ` & TCPIP-HOSTENT-ADDRESS-TYPE & `
TCPIP-HOSTENT-ADDRESS-LENGTH: ` & TCPIP-HOSTENT-ADDRESS-LENGTH & `
TCPIP-HOSTENT-NUM-ADDRESSES: ` & TCPIP-HOSTENT-NUM-ADDRESSES & ` 
TCPIP-HOSTENT-ADDRESS(` & counter & `): ` & TCPIP-HOSTENT-ADDRESS(counter) & ` 
TCPIP-HOSTENT-NUM-ALIASES: ` & TCPIP-HOSTENT-NUM-ALIASES & ` 
TCPIP-HOSTENT-ALIAS(` & counter & `): ` & TCPIP-HOSTENT-ALIAS(counter) & ` 
`.