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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Talking with your Web Browser - Take 2 1

Status
Not open for further replies.

CliveC

Programmer
Nov 21, 2001
1,222
US
Some time ago we disussed this in thread209-36997.

Thanks to two separate and unrelated posts by Jeminger and BigBadDave in the JavaSript forum I was able to piece together a solution, abeit IE only.

This solution is for client-side interfacing of the browser with PC COBOL.

It uses a form to write a text file MYFILE.TXT and then launhes the COBOL program MYCOBOL.EXE which could read and process the file MYFILE.TXT.

Here is the code: save it as MYDEMO.HTA.

<html><head>
<title>Using Your Browser as a COBOL Front-end</title>
<script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;>
function launch() {
document.writeln('<object width=&quot;1px&quot; height=&quot;1px&quot; classid=&quot;CLSID:018B7EC3-EECA-11d3-8E71-0000E82C6C0D&quot; codebase=&quot;MYCOBOL.EXE&quot;></object>')
}
</script>
<script type=&quot;text/vbscript&quot;>
sub writeToFile(s)
set oFS = createobject(&quot;scripting.filesystemobject&quot;)
set oFile = oFS.opentextfile(&quot;MYFILE.TXT&quot;, 8, true)
oFile.writeline(s)
oFile.close()
set oFile = nothing
set oFS = nothing
end sub
</script>
<meta http-equiv=&quot;Pragma&quot; content=&quot;no-cache&quot;>
</head>
<body>
<form name=&quot;form1&quot;>
<textarea name=&quot;ta&quot; rows=&quot;10&quot; cols=&quot;50&quot;></textarea><br />
<input type=&quot;button&quot; value=&quot;Launch COBOL&quot;
onClick=&quot;writeToFile(document.form1.ta.value);launch()&quot; />
</body></html>



Clive
 
Hi Clive,

I hope it works, I have not the time to test it now but I am very glad with your tip!

With Warm Regards,

Crox
 
I hope to have time for it soon so I will sure try it after a few weeks I hope...
 
Actually it can be tested as it is without a COBOL program. The fact that is managed to call (and the call failed) would be proof enough.

Alternatively just write a quick program with a single display.

The extension for the HTML code should be HTA. Just copy and paste the above code to a new text file, rename the text file to MYDEMO.HTA and click on it to execute.

HTA works only under windows with Internet Explorer.


Clive
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top