call system in MS Fortran 5.1

  • Follow


Hi,
I am having troubles regarding "call system" in MS Fortran 5.1.
Simply, it doesn't work...
I have copied the same code in Microsoft Fortran Power Station 4.0 and
everything is working just fine. Linker in MS Fortran 5.1 is saying
"error L2029: 'SYSTEM' : unresolved external" .

I don't have a clue how to make it work in MS Fortran 5.1. Am I
missing some libraries? Can anyone help me?

Thank you!

p.s. this is the line in my code:

      call system('c:\print.exe')

and print.exe is just printing something on computer screen...

0
Reply krivi 8/20/2010 12:38:57 PM

On 20 aug, 14:38, krivi <ivan.kriva...@gmail.com> wrote:
> Hi,
> I am having troubles regarding "call system" in MS Fortran 5.1.
> Simply, it doesn't work...
> I have copied the same code in Microsoft Fortran Power Station 4.0 and
> everything is working just fine. Linker in MS Fortran 5.1 is saying
> "error L2029: 'SYSTEM' : unresolved external" .
>
> I don't have a clue how to make it work in MS Fortran 5.1. Am I
> missing some libraries? Can anyone help me?
>
> Thank you!
>
> p.s. this is the line in my code:
>
> =A0 =A0 =A0 call system('c:\print.exe')
>
> and print.exe is just printing something on computer screen...

I do not know the particulars of MS Fortran 5.1 anymore, but I do know
that it has been out-of-date for at least 10 years.

Are you stuck with MS Fortran 5.1? Because there are plenty of
alternatives that are actively maintained, some free of charge.

Regards,

Arjen
0
Reply arjen.markus895 (633) 8/20/2010 12:59:10 PM


On 8/20/2010 5:38 AM, krivi wrote:
> Hi,
> I am having troubles regarding "call system" in MS Fortran 5.1.
> Simply, it doesn't work...
> I have copied the same code in Microsoft Fortran Power Station 4.0 and
> everything is working just fine. Linker in MS Fortran 5.1 is saying
> "error L2029: 'SYSTEM' : unresolved external" .
>
> I don't have a clue how to make it work in MS Fortran 5.1. Am I
> missing some libraries? Can anyone help me?
>
> Thank you!
>
> p.s. this is the line in my code:
>
>        call system('c:\print.exe')
>
> and print.exe is just printing something on computer screen...
>
If that compiler supports system() only as a function call, it may have 
been partly a matter of weak syntax checking if it worked in the earlier 
version.

-- 
Tim Prince
0
Reply Tim 8/20/2010 12:59:23 PM

krivi wrote:
....

> ... Linker in MS Fortran 5.1 is saying
> "error L2029: 'SYSTEM' : unresolved external" .
> 
> I don't have a clue how to make it work in MS Fortran 5.1. Am I
> missing some libraries? Can anyone help me?

....

I don't have the doc's in front of me and it's been a _LOOOOONG_ time 
since used it, but my recollection is that it's FSYSTEM in the MS 
compiler, not SYSTEM

Maybe Terence, the resident clf prime user of the compiler will chime in 
shortly.

I don't recall if there is a syntax reference in the help files on the 
distribution or not; likely one could find the doc's online if you don't 
have the printed manuals for the compiler.

--
0
Reply dpb 8/20/2010 1:01:51 PM

"krivi" <ivan.krivacic@gmail.com> wrote in message 
news:6a80ebbf-8023-4062-b1b8-e23e9dcdc2ef@x42g2000yqx.googlegroups.com...
> Hi,
> I am having troubles regarding "call system" in MS Fortran 5.1.
> Simply, it doesn't work...
> I have copied the same code in Microsoft Fortran Power Station 4.0 and
> everything is working just fine. Linker in MS Fortran 5.1 is saying
> "error L2029: 'SYSTEM' : unresolved external" .
>
> I don't have a clue how to make it work in MS Fortran 5.1. Am I
> missing some libraries? Can anyone help me?
>
> Thank you!
>
> p.s. this is the line in my code:
>
>      call system('c:\print.exe')
>
> and print.exe is just printing something on computer screen...
>

Try a web search in this newsgroup for "issue a win9x command from a 
fortran77 program".
In one reply, Myron Calhoun shows how to use the system FUNCTION from MS 
Fortran 5.1.

There are a couple of tricky things to get right.

0. The return type of the function.
1. The return code probably does not work.
2. The argument to the function needs to be a NUL terminated string.
'dir'C or does 'dir' // char(0) work?
and some ofther Microsoftisms.

But one of the rules of this newsgroup is that you can't post a request for 
help with very old, and in the case of FPS 4.0, very bug ridden Microsoft 
compilers without getting flamed! [smile] So why aren't you using a more 
modern compiler? G77 is free and is Fortran 77 plus extensions. G95 and 
Gfortran are both free. (Unless you are making Win 3.1 or Win 95 graphics 
applications.)





0
Reply epc8 (1259) 8/20/2010 3:34:59 PM

krivi <ivan.krivacic@gmail.com> wrote:

> I am having troubles regarding "call system" in MS Fortran 5.1.
> Simply, it doesn't work...

Why should it? That is not a part of standard Fortran. There are many
compilers it won't work in. That's the nature of nonstandard features.

Most compilers have something with functionality along the general lines
you are looking for, but the details vary quite a lot. Even among the
compilers that call it "system", it varies whether it is a function of
subroutine and exactly what arguments it has.

The best place to find out what your particular compiler has is in its
manuals. I did use to use MS Fortran 5.1 long ago. I'm pretty sure I
even have a copy saved away. The manuals might be a bit harder... Hmm...
Found some manuals for MS Fortran 4.0 (not Powerstation - that's
different), but not 5.1. At a quick skim, I don't see anything in the
4.0 manuals I have, but it doesn't look like a complete manual set
either. I have a user's guide and a quick reference guide, but I don't
see a language guide.

I'd recommend a newer compiler for many reasons, but I don't see the
point in belaboring them. Being easier to find documentation and support
is one of them.

-- 
Richard Maine                    | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle           |  -- Mark Twain
0
Reply nospam 8/20/2010 4:30:30 PM

On Aug 20, 7:38=A0am, krivi <ivan.kriva...@gmail.com> wrote:
> Hi,
> I am having troubles regarding "call system" in MS Fortran 5.1.
> Simply, it doesn't work...
> I have copied the same code in Microsoft Fortran Power Station 4.0 and
> everything is working just fine. Linker in MS Fortran 5.1 is saying
> "error L2029: 'SYSTEM' : unresolved external" .
>
> I don't have a clue how to make it work in MS Fortran 5.1. Am I
> missing some libraries? Can anyone help me?
>
> Thank you!
>
> p.s. this is the line in my code:
>
> =A0 =A0 =A0 call system('c:\print.exe')
>
> and print.exe is just printing something on computer screen...

I have the complete manual set at home, i'll check later today.
0
Reply garylscott (1357) 8/20/2010 4:44:16 PM

On 2010-08-20 13:44:16 -0300, GaryScott <garylscott@sbcglobal.net> said:

> On Aug 20, 7:38�am, krivi <ivan.kriva...@gmail.com> wrote:
>> Hi,
>> I am having troubles regarding "call system" in MS Fortran 5.1.
>> Simply, it doesn't work...
>> I have copied the same code in Microsoft Fortran Power Station 4.0 and
>> everything is working just fine. Linker in MS Fortran 5.1 is saying
>> "error L2029: 'SYSTEM' : unresolved external" .
>> 
>> I don't have a clue how to make it work in MS Fortran 5.1. Am I
>> missing some libraries? Can anyone help me?
>> 
>> Thank you!
>> 
>> p.s. this is the line in my code:
>> 
>> � � � call system('c:\print.exe')
>> 
>> and print.exe is just printing something on computer screen...
> 
> I have the complete manual set at home, i'll check later today.

Pehaps it is SYSTEMQQ on MS 5.1 as I seem to recall lots of QQ decorations.



0
Reply Gordon 8/20/2010 4:46:42 PM

On Aug 20, 11:46=A0am, Gordon Sande <Gordon.Sa...@gmail.com> wrote:
> On 2010-08-20 13:44:16 -0300, GaryScott <garylsc...@sbcglobal.net> said:
>
>
>
>
>
> > On Aug 20, 7:38=A0am, krivi <ivan.kriva...@gmail.com> wrote:
> >> Hi,
> >> I am having troubles regarding "call system" in MS Fortran 5.1.
> >> Simply, it doesn't work...
> >> I have copied the same code in Microsoft Fortran Power Station 4.0 and
> >> everything is working just fine. Linker in MS Fortran 5.1 is saying
> >> "error L2029: 'SYSTEM' : unresolved external" .
>
> >> I don't have a clue how to make it work in MS Fortran 5.1. Am I
> >> missing some libraries? Can anyone help me?
>
> >> Thank you!
>
> >> p.s. this is the line in my code:
>
> >> =A0 =A0 =A0 call system('c:\print.exe')
>
> >> and print.exe is just printing something on computer screen...
>
> > I have the complete manual set at home, i'll check later today.
>
> Pehaps it is SYSTEMQQ on MS 5.1 as I seem to recall lots of QQ decoration=
s.- Hide quoted text -
>
> - Show quoted text -

Very possible, definitely in the 32-bit compilers.  I just can't
remember back that far.
0
Reply garylscott (1357) 8/20/2010 5:03:14 PM

krivi wrote:
> Hi,
> I am having troubles regarding "call system" in MS Fortran 5.1.
> Simply, it doesn't work...
> I have copied the same code in Microsoft Fortran Power Station 4.0 and
> everything is working just fine. Linker in MS Fortran 5.1 is saying
> "error L2029: 'SYSTEM' : unresolved external" .
> 
> I don't have a clue how to make it work in MS Fortran 5.1. Am I
> missing some libraries? Can anyone help me?
> 
> Thank you!
> 
> p.s. this is the line in my code:
> 
>       call system('c:\print.exe')
> 
> and print.exe is just printing something on computer screen...
> 
Because system is a function in 5.1?
 From a working program:
..
..
..
	integer*2 system
..
..
..
..
..
..
..
	i=system('dirsort en'c)
..                            ^
..
!the string should be a C string wich is done by the trailing C char.
A fortran string is likely to produce a garbage result.
The systemfile below suggests checking the "advanced topics" guide.
Checking that,page 60 and 62:
Yes. page 60 confirms the usage shown, and warns about the C string
implementation(fortran string: "dir c:"   C string: "dir c:"C  )



 From a system file:
----------------------------------------------------------------------
C       EXEC.FI - Interface file for C system and spawnlp routines

C       These functions are discussed in Chapter 3 of the Advanced Topics
C       manual. The program DEMOEXEC.FOR illustrates how to use the include
C       file and the functions.


C       Function:       SYSTEM
C
C       Purpose:        Starts a child copy of the DOS system shell
C                       program--COMMAND.COM
C
C       Argument:       string - A string (in C format) consisting
C                       of a DOS command, program, or batch file name
C                       followed optionally by arguments
C
C       Return:         INTEGER*2 - 0 for success, or -1 for fail
C
C       Example:        dummy2 = SYSTEM( 'dir *.for'C )

         INTERFACE TO FUNCTION SYSTEM[C] (STRING)
         INTEGER*2 SYSTEM
         CHARACTER*1 STRING[REFERENCE]
         END
0
Reply burrynulnulfour (424) 8/20/2010 5:13:13 PM

krivi wrote:
> Hi,
> I am having troubles regarding "call system" in MS Fortran 5.1.
> Simply, it doesn't work...
> I have copied the same code in Microsoft Fortran Power Station 4.0 and
> everything is working just fine. Linker in MS Fortran 5.1 is saying
> "error L2029: 'SYSTEM' : unresolved external" .
> 
> I don't have a clue how to make it work in MS Fortran 5.1. Am I
> missing some libraries? Can anyone help me?
> 
> Thank you!
> 
> p.s. this is the line in my code:
> 
>       call system('c:\print.exe')
> 
> and print.exe is just printing something on computer screen...
> 
Oh and I forgot to tell:
Include the interface file at the start of your code:
	include  'EXEC.FI'
0
Reply Sjouke 8/20/2010 5:15:55 PM

Sjouke Burry wrote:
> krivi wrote:
>> Hi,
>> I am having troubles regarding "call system" in MS Fortran 5.1.
>> Simply, it doesn't work...
>> I have copied the same code in Microsoft Fortran Power Station 4.0 and
>> everything is working just fine. Linker in MS Fortran 5.1 is saying
>> "error L2029: 'SYSTEM' : unresolved external" .
>>
>> I don't have a clue how to make it work in MS Fortran 5.1. Am I
>> missing some libraries? Can anyone help me?
>>
>> Thank you!
>>
>> p.s. this is the line in my code:
>>
>> call system('c:\print.exe')
>>
>> and print.exe is just printing something on computer screen...
>>
> Oh and I forgot to tell:
> Include the interface file at the start of your code:
> include 'EXEC.FI'

I had trouble finding that 'exec.fi' file in my little experiment here. 
It seems to reside in the samples folder. I copied and pasted the 
interface block, and it worked okay.

         INTERFACE TO FUNCTION SYSTEM[C] (STRING)
         INTEGER*2 SYSTEM
         CHARACTER*1 STRING[REFERENCE]
         END


         program test1
         integer*2 system
         print *,'Hello WorldF'
         i=system('dir'C)
         end

0
Reply user1 8/20/2010 9:58:19 PM

user1 wrote:
> Sjouke Burry wrote:
>> krivi wrote:
>>> Hi,
>>> I am having troubles regarding "call system" in MS Fortran 5.1.
>>> Simply, it doesn't work...
>>> I have copied the same code in Microsoft Fortran Power Station 4.0 and
>>> everything is working just fine. Linker in MS Fortran 5.1 is saying
>>> "error L2029: 'SYSTEM' : unresolved external" .
>>>
>>> I don't have a clue how to make it work in MS Fortran 5.1. Am I
>>> missing some libraries? Can anyone help me?
>>>
>>> Thank you!
>>>
>>> p.s. this is the line in my code:
>>>
>>> call system('c:\print.exe')
>>>
>>> and print.exe is just printing something on computer screen...
>>>
>> Oh and I forgot to tell:
>> Include the interface file at the start of your code:
>> include 'EXEC.FI'
> 
> I had trouble finding that 'exec.fi' file in my little experiment here. 
> It seems to reside in the samples folder. I copied and pasted the 
> interface block, and it worked okay.
> 
>          INTERFACE TO FUNCTION SYSTEM[C] (STRING)
>          INTEGER*2 SYSTEM
>          CHARACTER*1 STRING[REFERENCE]
>          END
> 
> 
>          program test1
>          integer*2 system
>          print *,'Hello WorldF'
>          i=system('dir'C)
>          end
> 
Its better to include that file, it should be in the
"include" directory, in my case: C:\FORTRAN\INCLUDE.
It seems that your fortran install is incomplete.

Succes with your application.
0
Reply Sjouke 8/21/2010 12:05:17 AM

On Aug 20, 10:38=A0pm, krivi <ivan.kriva...@gmail.com> wrote:
> Hi,
> I am having troubles regarding "call system" in MS Fortran 5.1.
> Simply, it doesn't work...
> I have copied the same code in Microsoft Fortran Power Station 4.0 and
> everything is working just fine. Linker in MS Fortran 5.1 is saying
> "error L2029: 'SYSTEM' : unresolved external" .
>
> I don't have a clue how to make it work in MS Fortran 5.1. Am I
> missing some libraries? Can anyone help me?
>
> Thank you!
>
> p.s. this is the line in my code:
>
> =A0 =A0 =A0 call system('c:\print.exe')
>
> and print.exe is just printing something on computer screen...


Sorry I didn't see this earlier.
With 5.1 you have to include  FOREXEC.INC in the main program, and
link with the c libaray that comes with the fortran named CEXEC.lib

Here is the example from the compiler
c       FOREXEC.INC - interface file for C library routines

c       This include file along with the CEXEC.LIB library has been
included
c       with your FORTRAN 3.30 to show you how easy it is to call
routines
c       written in our new C 3.00 release.  The CEXEC.LIB contains
several
c       routines from the C library which we think you will find
useful in
c       extending the power of your FORTRAN programs.
c
c       The new Microsoft FORTRAN 3.30, PASCAL 3.30, and C 3.00
releases
c       have been designed so that libraries or subprograms can be
written
c       in any one of these languages and used in any other.
c
c       Try compiling and running the demonstration program
DEMOEXEC.FOR
c       to see some actual examples.

c       C function
c
c               int system(string)
c                       char *string;
c
c       The system() function passes the given C string (00hex
terminated)
c       to the DOS command interpreter (COMMAND.COM), which interprets
and
c       executes the string as an MS-DOS command.  This allows MS-DOS
commands
c       (i.e., DIR or DEL), batch files, and programs to be executed.
c
c       Example usage in FORTRAN
c
c       integer*2 system                (the return type must be
declared)
c       ...
c       i =3D system('dir *.for'c)        (notice the C literal string
'...'c)
c
c       The interface to system is given below.  The [c] attribute is
given
c       after the function name.  The argument string has the
attribute
c       [reference] to indicate that the argument is passed by
reference.
c       Normally, arguments are passed to C procedures by value.

        interface to integer*2 function system [c]
     +          (string[reference])
        character*1 string
        end


c       C function
c
c       int spawnlp(mode,path,arg0,arg1,...,argn)
c               int mode;               /* spawn mode */
c               char *path;             /* pathname of program to
execute */
c               char *arg0;             /* should be the same as path
*/
c               char *arg1,...,*argn;   /* command line arguments */
c                                       /* argn must be NULL */
c
c       The spawnlp (to be referenced in FORTRAN as spawn) creates and
c       executes a new child process.  There must be enough memory to
load
c       and execute the child process.  The mode argument determines
which
c       form of spawn is executed as follows:
c
c           Value       Action
c
c             0         Suspend parent program and execute the child
program.
c                       When the child program terminates, the parent
program
c                       resumes execution.  The return value from
spawn is -1
c                       if an error has occured or if the child
process has
c                       run, the return value is the child processes
return
c                       code.
c
c             2         Overlay parent program with the child
program.  The
c                       child program is now the running process and
the
c                       parent process is terminated.  spawn only
returns
c                       a value if there has been a recoverable
error.  Some
c                       errors can not be recovered from and execution
will
c                       terminate by safely returning to DOS.  This
might
c                       happen if there is not enough memory to run
the new
c                       process.
c
c       The path argument specifies the file to be executed as the
child
c       process.  The path can specify a full path name (from the root
c       directory \), a partial path name (from the current working
directory),
c       or just a file name.  If the path argument does not have a
filename
c       extension or end with a period (.), the spawn call first
appends
c       the extension ".COM" and searches for the file; if
unsuccessful, the
c       extension ".EXE" is tried.  The spawn routine will also search
for
c       the file in any of the directories specified in the PATH
environment
c       variable (using the same procedure as above).
c
c       Example usage in FORTRAN
c
c       integer*2 spawn                 (the return type must be
declared)
c       ...
c       i =3D spawn(0, loc('exemod'c), loc('exemod'c),
c    +          loc('demoexec.exe'c), int4(0))          (execute as a
child)
c
c       The interface to spawnlp is given below.  The [c] attribute is
given
c       after the function name.  The [varying] attribute indicates
that a
c       variable number of arguments may be given to the function.
The
c       [alias] attribute has to be used because the C name for the
function
c       spawnlp has 7 characters.  Names in FORTRAN are only
significant to
c       6 characters, so we 'alias' the FORTRAN name spawn to the
actual C
c       name spawnlp.  Notice in the example above the C strings are
passed
c       differently from the system function.  This is because the
string
c       arguments to spawn are undeclared in the interface below and
assumed
c       to be passed by value.  The C spawnlp function is expecting
the
c       addresses of the strings (not the actual characters), so we
use the
c       LOC() function to pass the address (remember that functions
with the
c       [c] attribute pass arguments by value).  The last parameter to
the
c       spawn routine must be a C NULL pointer which is a 32-bit
integer 0,
c       so we use the INT4(0) function to pass this number by value as
the
c       last parameter.

        interface to integer*2 function spawn
     +          [c,varying,alias:'spawnlp']
     +          (mode)
        integer*2 mode
        end
0
Reply tbwright (1098) 8/21/2010 12:25:26 AM

On Aug 21, 10:25=A0am, Terence <tbwri...@cantv.net> wrote:
Yes I know, the files said MS v3.0, were from MS v3.31, but apply to
v5.1 which I have too.
0
Reply Terence 8/21/2010 9:16:38 AM

Sjouke Burry wrote:

[snip]

>>
> Its better to include that file, it should be in the
> "include" directory, in my case: C:\FORTRAN\INCLUDE.
> It seems that your fortran install is incomplete.
>
> Succes with your application.

Not that it matters much, but I am not the OP, and it was a fresh 
install. I tend to think that you manually copied exec.fi to the include 
directory at some point.

The MS packing list for 5.1 is still online, and lists exec.fi and 
demoexec.for as demo programs on disk 6. If the OP did not install the 
samples, he will have to pull it from this disk.

http://support.microsoft.com/kb/73267

0
Reply user1 8/21/2010 12:17:40 PM

On 21 kol, 14:17, user1 <us...@example.net> wrote:
> Sjouke Burry wrote:
>
> [snip]
>
>
>
> > Its better to include that file, it should be in the
> > "include" directory, in my case: C:\FORTRAN\INCLUDE.
> > It seems that your fortran install is incomplete.
>
> > Succes with your application.
>
> Not that it matters much, but I am not the OP, and it was a fresh
> install. I tend to think that you manually copied exec.fi to the include
> directory at some point.
>
> The MS packing list for 5.1 is still online, and lists exec.fi and
> demoexec.for as demo programs on disk 6. If the OP did not install the
> samples, he will have to pull it from this disk.
>
> http://support.microsoft.com/kb/73267



First, one big "Thanks" to everybody...

Problem is solved.

I have looked at demoexec.for and tried to execute it, but it has
failed to execute...
Linker was missing some libraries, but I didn't know which ones. I've
included all of them. Nothing.

I've repeated whole MS Fortran 5.1 installation, and the key library
to get it work was LCLIB1.lib, which I didn't had in my first
version... :)

p.s. use double backslash when giving a path...

This is the part of my program:

$INCLUDE: 'EXEC.FI'

        INTEGER*2 SYSTEM
        I = SYSTEM ( 'cd c:\\pro\\sys'C )
        I = SYSTEM ( 'start'C )

      end



0
Reply krivi 8/23/2010 10:35:05 AM

16 Replies
454 Views

(page loaded in 0.206 seconds)

Similiar Articles:


















7/24/2012 10:35:25 AM


Reply: