For Programmers: Free Programming Magazines  


Home > Archive > Cobol > January 2005 > Call compiler from within an application?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Call compiler from within an application?
Chris

2005-01-15, 8:55 am

I know that from with a COBOL app, you can use something like:

CALL "SYSTEM" USING Z"cob ..."

I know its out there, but I am wondering if its even possible, does
anyone knows of a way for a cobol application to directly invoke the
compiler?

William M. Klein

2005-01-15, 8:55 am

Probably possible. What compiler? What operating system?

--
Bill Klein
wmklein <at> ix.netcom.com
"Chris" <ctaliercio@yahoo.com> wrote in message
news:1105475559.668451.308500@c13g2000cwb.googlegroups.com...
>I know that from with a COBOL app, you can use something like:
>
> CALL "SYSTEM" USING Z"cob ..."
>
> I know its out there, but I am wondering if its even possible, does
> anyone knows of a way for a cobol application to directly invoke the
> compiler?
>



docdwarf@panix.com

2005-01-15, 8:55 am

In article <9hjcu05uvr1sbfv7b9hu572rid7kr32uid@4ax.com>,
Robert Wagner <spamblocker-robert@wagner.net> wrote:
>On 12 Jan 2005 11:24:09 -0800, "Richard" <riplin@Azonic.co.nz> wrote:
>
>
>It can be easily tested. At a Unix prompt, type:
>
>ksh
>export test=xyz
>exit
>echo $test
>
>I'd post the result if I had access to a Unix machine.


panix5:[/net/u/1/d/docdwarf] ksh
$ export test=xyz
$ exit
panix5:[/net/u/1/d/docdwarf] echo $test
test: Undefined variable.
panix5:[/net/u/1/d/docdwarf]

DD

Peter Lacey

2005-01-15, 8:55 am

Chris wrote:
>
> I know that from with a COBOL app, you can use something like:
>
> CALL "SYSTEM" USING Z"cob ..."
>
> I know its out there, but I am wondering if its even possible, does
> anyone knows of a way for a cobol application to directly invoke the
> compiler?


I don't know about Cobol, but my experiences with PROGRESS, which does
allow compile-on-the-fly, lead me to believe that there is never a case
where this is a good idea.



PL
Richard

2005-01-15, 8:55 am

> CALL "SYSTEM" USING Z"cob ..."

> I know its out there, but I am wondering if its even possible, does
> anyone knows of a way for a cobol application to directly invoke the
> compiler?


What would be different between your example invoking 'cob' (the
compiler) and 'directly invoking the compiler' ?

Were you wanting a program to get itself recompiled in a way that then
carried on in the newly recompiled version ?

Richard

2005-01-15, 3:55 pm

> I could swear on a stack of manuals I've done it many times.

Which is probably why you have a reputation of being a mine of
misinformation.

Richard

2005-01-15, 3:55 pm

>> No, you cannot do that, it will not and does not work.

destroyed[color=darkred]
[color=darkred]
> It can be easily tested. At a Unix prompt, type:


> ksh


on Linux:
[riplin@Man91 EMail]$ ksh
bash: ksh: command not found

on SCO Unixware:
$ ksh
$ export test=xyz
$ exit
$ echo $test
<- blank
$

I actually tested _before_ I posted by having a Cobol program execute a
script and try to retrieve the result of an export in the script. It
failed to do so, as I had already predicted from my knowledge of Unix
and shells.

To illustrate how far off the mark you are:

$ test=old
$ ksh
$ export test=xyz
$ echo $test
xyz
$ exit
$ echo $test
old
$

This is _why_ they are called 'shells'.

LX-i

2005-01-17, 8:55 pm

Robert Wagner wrote:
> On 12 Jan 2005 11:24:09 -0800, "Richard" <riplin@Azonic.co.nz> wrote:
>
>
>
>
> It can be easily tested. At a Unix prompt, type:
>
> ksh
> export test=xyz
> exit
> echo $test
>


And that gets you...

[summersd@daniel summersd]$ ksh
$ export test=xyz
$ exit
[summersd@daniel summersd]$ echo $test

[summersd@daniel summersd]$


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~ / \ / ~ Live from Montgomery, AL! ~
~ / \/ o ~ ~
~ / /\ - | ~ LXi0007@Netscape.net ~
~ _____ / \ | ~ http://www.knology.net/~mopsmom/daniel ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ I do not read e-mail at the above address ~
~ Please see website if you wish to contact me privately ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ GEEKCODE 3.12 GCS/IT d s-:+ a C++ L++ E--- W++ N++ o? K- w$ ~
~ !O M-- V PS+ PE++ Y? !PGP t+ 5? X+ R* tv b+ DI++ D+ G- e ~
~ h---- r+++ z++++ ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~

Richard

2005-01-19, 3:55 am

> Call SYSTEM to run a script containing two entries: make followed by
> export rc=$?
> Then you can interrogate rc to get the compiler's return code.


No, you cannot do that, it will not and does not work.

The 'system' call creates a new shell below the current one. Any
'export' only changes what is in that new shell and this is destroyed
before the 'system' returns to the program.

Richard

2005-01-19, 3:55 am

>> No, you cannot do that, it will not and does not work.

destroyed[color=darkred]
[color=darkred]
> It can be easily tested. At a Unix prompt, type:


> ksh


on Linux:
[riplin@Man91 EMail]$ ksh
bash: ksh: command not found

on SCO Unixware:
$ ksh
$ export test=xyz
$ exit
$ echo $test
<- blank
$

I actually tested _before_ I posted by having a Cobol program execute a
script and try to retrieve the result of an export in the script. It
failed to do so, as I had already predicted from my knowledge of Unix
and shells.

To illustrate how far off the mark you are:

$ test=old
$ ksh
$ export test=xyz
$ echo $test
xyz
$ exit
$ echo $test
old
$

This is _why_ they are called 'shells'.

Richard

2005-01-19, 3:55 am

> I could swear on a stack of manuals I've done it many times.

Which is probably why you have a reputation of being a mine of
misinformation.

Richard

2005-01-19, 3:55 am

> I know I could parse the results of a SYSTEM call or an input pipe
> file, but that seems tedious and gives me no way to interrogate the
> return status of the compile command itself.


I suspect that 'cob' is written in Cobol, much of the MF compiler suite
is. So it should be possible to call the compiler and get the result,
but then you may never know what this result actually means.

I would have thought that using some sort of 'make' would be more
useful than writing your own. One of the dependent actions could be to
signal somehow that it completed correctly.

eg:

YourProgram:
writes makefile
writes resultfile with 'failed' in it
call "SYSTEM" using z"make ...."
reads resultfile
if result-record = 'failed'
......

Makefile:
prog: prog.cbl ....
cob ... prog.cbl ...
echo "success" > resultfile

if 'cob' fails then it should not run echo.

Alternately delete the executable before call "SYSTEM" ... and see if
one exists after then it worked.

Chris

2005-01-19, 3:55 am

Sorry for not providing the usual details: HP-UX 11i & MF Server
Express 4.0 SP1

Also, I'm not trying to recompile the running program, I'm attempting
to write an application that will have the ability to "build" other
applications on the fly. The only reason for asking whether or not I
could invoke the compiler from within the rts is simply because I felt
that it would provide me with the easiest method of obtaining the
feedback.

I know I could parse the results of a SYSTEM call or an input pipe
file, but that seems tedious and gives me no way to interrogate the
return status of the compile command itself.

In all actuality, I'll probably end up using the SYSTEM call, since I
would then be able to "build" applications other than COBOL from with
the MF rts. I was more curious if anyone had ever been able to
accomplish this before.

Thanks again for the responses - this is a very bright group of
individuals.

Robert Wagner

2005-01-19, 3:55 am

On 12 Jan 2005 11:24:09 -0800, "Richard" <riplin@Azonic.co.nz> wrote:

>
>No, you cannot do that, it will not and does not work.
>
>The 'system' call creates a new shell below the current one. Any
>'export' only changes what is in that new shell and this is destroyed
>before the 'system' returns to the program.


It can be easily tested. At a Unix prompt, type:

ksh
export test=xyz
exit
echo $test

I'd post the result if I had access to a Unix machine.

Donald Tees

2005-01-19, 3:55 am

James J. Gavan wrote:
> Chris wrote:
>
> Come on Donald - you are are one who has expressed an interest in
> compiling on the fly. Care to give Chris some of your thoughts
> ("expanded") ? Have you had a shot yet with either F/J or M/F ? It's not
> Friday yet, so you aren't into a stogie or fiddling :-)
>
> Jimmy, Calgary AB


I cannot see the difference between calling a cobol compiler and calling
any other application. A program is a program is a program. You have to
also call the linker, of course.

As Richard said a post or two back, the easiest way is to call a
makefile, rather than wading through all the options and stuff. The FJ
Gui(PSTAFF) will even write the makefile out for you, based on the project.

Donald


Robert Wagner

2005-01-19, 3:55 am

On 13 Jan 2005 07:33:15 -0500, docdwarf@panix.com wrote:

>In article <9hjcu05uvr1sbfv7b9hu572rid7kr32uid@4ax.com>,
>Robert Wagner <spamblocker-robert@wagner.net> wrote:
>
>panix5:[/net/u/1/d/docdwarf] ksh
>$ export test=xyz
>$ exit
>panix5:[/net/u/1/d/docdwarf] echo $test
>test: Undefined variable.
>panix5:[/net/u/1/d/docdwarf]


Thank you.

I could swear on a stack of manuals I've done it many times.
LX-i

2005-01-19, 3:55 am

Robert Wagner wrote:
> On 12 Jan 2005 11:24:09 -0800, "Richard" <riplin@Azonic.co.nz> wrote:
>
>
>
>
> It can be easily tested. At a Unix prompt, type:
>
> ksh
> export test=xyz
> exit
> echo $test
>


And that gets you...

[summersd@daniel summersd]$ ksh
$ export test=xyz
$ exit
[summersd@daniel summersd]$ echo $test

[summersd@daniel summersd]$


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~ / \ / ~ Live from Montgomery, AL! ~
~ / \/ o ~ ~
~ / /\ - | ~ LXi0007@Netscape.net ~
~ _____ / \ | ~ http://www.knology.net/~mopsmom/daniel ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ I do not read e-mail at the above address ~
~ Please see website if you wish to contact me privately ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ GEEKCODE 3.12 GCS/IT d s-:+ a C++ L++ E--- W++ N++ o? K- w$ ~
~ !O M-- V PS+ PE++ Y? !PGP t+ 5? X+ R* tv b+ DI++ D+ G- e ~
~ h---- r+++ z++++ ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~

docdwarf@panix.com

2005-01-20, 3:55 pm

In article <qc3du0hkbdfusmoqthdknu5nratgj2qvhe@4ax.com>,
Robert Wagner <spamblocker-robert@wagner.net> wrote:
>On 13 Jan 2005 07:33:15 -0500, docdwarf@panix.com wrote:
>
>
>Thank you.
>
>I could swear on a stack of manuals I've done it many times.


That might show the value of your oath, Mr Wagner, when compared with an
experiment.

DD

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com