gfxgfx
 
Please login or register.

Login with username, password and session length
 
gfx gfx
gfx
1617 Posts in 535 Topics by 779 Members - Latest Member: rhoronjeff@comcast.net December 07, 2022, 05:43:33 PM
*
gfx* Home | Help | Search | Login | Register | gfx
gfx
Absoft User Forum  |  Support  |  General  |  doen “call system” work in absoft fortran
gfx
gfxgfx
 

Author Topic: doen “call system” work in absoft fortran  (Read 348 times)

ustbszr

  • Newbie
  • *
  • Posts: 2
doen “call system” work in absoft fortran
« on: September 10, 2022, 03:42:08 AM »
when I want to execute shell commands on Windos, I used call system(),but I got an link error: undefined symbol - _SYSTEM.
Doen “call system” work in absoft fortran? if not,is there any way can do the same thing?
Hope to hear your advice.
thx.
by the way,I am using absoft fortran pro 8.0.And the compiler is f95.

Mike Linacre

  • Sr. Member
  • ****
  • Posts: 259
Re: doen “call system” work in absoft fortran
« Reply #1 on: September 10, 2022, 05:31:56 AM »
Hi ustbszr:

How about coding the Windows API directly, similar to:

       integer(kind=4), external, stdcall :: ShellExecuteA

          RetVal = ShellExecuteA(
     + val(g_hWndChild), ! this can probably be 0
     + val(loc(TRIMCHARLINE)),  ! string ending with char(0)
     + val(loc(TRIMCHARLINE2)), ! string ending with char(0)
     + val(loc(CHAR0)), ! string containing char(0)
     + val(loc(CHAR0)), ! string containing char(0)
     + val(SW_SHOWNORMAL))  ! value is 1

And also include the Windows library: Shell32.lib

This is not elegant code, but it works!  + shows continuation

forumadmin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 333
Re: doen “call system” work in absoft fortran
« Reply #2 on: September 10, 2022, 09:18:52 AM »
The SYSTEM call is part of the Unix compatibility library. Although later versions of Pro Fortran will link this library automatically, version 8.0 requires that you add it yourself.  For a simple command line compilation on Windows, this looks like:

  f95  source.f90  unix.lib

If you are using the Absoft Developer Tools Interface from 8.0, there is a UNIX Library option on the Target page of the Options dialog.

You can find more information on the Unix compatibilty library in the Support Library.pdf document located in your Absoft complier documentation folder, typically C:\Absoft80\DOCUMENTATION.

There is one thing to note about SYSTEM routine implementation in the Windows Pro Fortran compiler. Some common operations that people want to use SYSTEM for are not actually programs. For example, copying one file to another using COPY. The "COPY" command is built in to the Window's command processor CMD.EXE, there is no COPY.EXE program to run. To run COPY, or any of the other built in commands, you need to run CMD.EXE and give COPY as an argument. Here is a sample call to SYSTEM that will execute the COPY command:
 
    CALL SYSTEM("CMD.EXE /C COPY file1 file2")
 
The "/C" option tells CMD.EXE to carry out the COPY command and stop.
« Last Edit: September 10, 2022, 10:18:17 AM by forumadmin »

ustbszr

  • Newbie
  • *
  • Posts: 2
Re: doen “call system” work in absoft fortran
« Reply #3 on: September 10, 2022, 10:02:57 PM »
Hi ustbszr:

How about coding the Windows API directly, similar to:

       integer(kind=4), external, stdcall :: ShellExecuteA

          RetVal = ShellExecuteA(
     + val(g_hWndChild), ! this can probably be 0
     + val(loc(TRIMCHARLINE)),  ! string ending with char(0)
     + val(loc(TRIMCHARLINE2)), ! string ending with char(0)
     + val(loc(CHAR0)), ! string containing char(0)
     + val(loc(CHAR0)), ! string containing char(0)
     + val(SW_SHOWNORMAL))  ! value is 1

And also include the Windows library: Shell32.lib

This is not elegant code, but it works!  + shows continuation

The SYSTEM call is part of the Unix compatibility library. Although later versions of Pro Fortran will link this library automatically, version 8.0 requires that you add it yourself.  For a simple command line compilation on Windows, this looks like:

  f95  source.f90  unix.lib

If you are using the Absoft Developer Tools Interface from 8.0, there is a UNIX Library option on the Target page of the Options dialog.

You can find more information on the Unix compatibilty library in the Support Library.pdf document located in your Absoft complier documentation folder, typically C:\Absoft80\DOCUMENTATION.

There is one thing to note about SYSTEM routine implementation in the Windows Pro Fortran compiler. Some common operations that people want to use SYSTEM for are not actually programs. For example, copying one file to another using COPY. The "COPY" command is built in to the Window's command processor CMD.EXE, there is no COPY.EXE program to run. To run COPY, or any of the other built in commands, you need to run CMD.EXE and give COPY as an argument. Here is a sample call to SYSTEM that will execute the COPY command:
 
    CALL SYSTEM("CMD.EXE /C COPY file1 file2")
 
The "/C" option tells CMD.EXE to carry out the COPY command and stop.

Both replies are very helpful!
thx for your time

Absoft User Forum  |  Support  |  General  |  doen “call system” work in absoft fortran
 

gfxgfx
gfx gfx
Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!