Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using your Browser as a COBOL front-end

Status
Not open for further replies.

CliveC

Programmer
Nov 21, 2001
1,222
US
I posted something like this sometime ago but since then Microsoft IE6 updates prevented it from working. Here is the latest version which has been tested with the latest Internet Explorer 6 updates.

It allows you to use your IE6 browser on the client-side to provide a GUI front-end interface to a COBOL PC program. To bypass browser security without updating your browser settings, use an HTA extension instead of an HTM extension.

This example brings up a text-box in a browser. Type in something and then click launch COBOL. Whatever you typed in will be written to a file, MYFILE.TXT. The COBOL program opens MYFILE.TXT and, for the purpose of this example, reads the record and writes it out to a new file OUTFILE.TXT. When the COBOL program has executed the browser will close.

IE6TOCBL.hta (browser filename)
*************************************
<html><head>
<title>Using Your Browser as a COBOL Front-end</title>
<meta http-equiv=&quot;Pragma&quot; content=&quot;no-cache&quot;>

<!--
**** This javascript subroutine is called when
**** the form's &quot;Launch COBOL&quot; button is clicked.
**** It calls two subroutines, writeToFile & Launch.
-->
<script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;>
function process(data) {
writeToFile(data);
timer=setTimeout('launch()',5000)
}
</script>

<!--
**** This vbscript subroutine is called to write
**** the contents of the textarea to a file.
**** In this case the file is name MYFILE.TXT
-->
<script type=&quot;text/vbscript&quot;>
sub writeToFile(data)
set oFS = createobject(&quot;scripting.filesystemobject&quot;)
set oFile = oFS.opentextfile(&quot;MYFILE.TXT&quot;, 2, true)
oFile.writeline(data)
oFile.close()
set oFile = nothing
set oFS = nothing
end sub
</script>

<!--
//**** This javascript subroutine is called after
//**** the form's data has been written to a file.
//**** It will launch the COBOL program which will
//**** read the file. In this case the program is
//**** called, MYCOBOL.EXE
-->
<script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;>
function launch() {
document.writeln('MYCOBOL.EXE STARTED<br />')
document.writeln('Please Wait...<br /><br />')
document.writeln('<object width=&quot;0px&quot; height=&quot;0px&quot;')
document.writeln('classid=&quot;CLSID:018B7EC3-EECA-11d3-8E71-0000E82C6C0D&quot;')
document.writeln('codebase=&quot;MYCOBOL.EXE&quot;></object>')
timer=setTimeout('window.close()',10000)
}
</script>

<!-- **** This is the HTML for the form **** -->
</head><body style=&quot;background:yellow&quot;><form name=&quot;form1&quot;>
<textarea name=&quot;ta&quot; rows=&quot;10&quot; cols=&quot;50&quot;></textarea>
<br /><br />
<input type=&quot;button&quot; value=&quot;Launch COBOL&quot;
onClick=&quot;process(document.form1.ta.value)&quot; />
</form>
</body></html>

COMPILE THIS PROGRAM TO MYCOBOL.EXE:

IDENTIFICATION DIVISION.
PROGRAM-ID. MYCOBOL.
AUTHOR. CLIVE CUMMINS.
INSTALLATION. DATE-WRITTEN. Nov 23,2003.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT MYCOBOL-FILE ASSIGN TO MYCOBOL-FILE-ID
FILE STATUS IS MYCOBOL-RETURN-CODE
ACCESS MODE IS SEQUENTIAL
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD MYCOBOL-FILE.
01 MYCOBOL-RECORD PIC X(4000).
WORKING-STORAGE SECTION.
01 MYCOBOL-PARAMETERS.
05 MYCOBOL-RECORD-WORK PIC X(4000).
05 MYCOBOL-FILE-ID PIC X(12)
VALUE &quot;MYFILE.TXT&quot;.
05 MYCOBOL-RETURN-CODE PIC X(2).
PROCEDURE DIVISION.
OPEN INPUT MYCOBOL-FILE.
READ MYCOBOL-FILE INTO MYCOBOL-RECORD-WORK.
CLOSE MYCOBOL-FILE.
MOVE &quot;OUTFILE.TXT&quot; TO MYCOBOL-FILE-ID.
OPEN OUTPUT MYCOBOL-FILE.
WRITE MYCOBOL-RECORD FROM MYCOBOL-RECORD-WORK.
CLOSE MYCOBOL-FILE.
GOBACK.








Clive
 
Thanks for this Clive. I'm sure I shall use it, just waiting for the time and application.
Marc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top