I am looking for alternative functions for the below list of Realia functions. Can you please help?
REALIA_GET_PARM_COUNT - Get number of parameters passed
REALIA_FINDFIRST - Find first file
REALIA_FINDNEXT - Find next file
REALIA_FINDCLOSE - Close the find handle
REALIA_GET_COMMAND_NAME - Return the name of the current program
REALIA_EXEC_PROGRAM - Execute a program
01 PROCESS-HANDLE PIC S9(9) BINARY.
01 PROG-NAME PIC X(260).
01 COMMAND-LINE PIC X(1024).
01 STATUS-CODE PIC S9(9) BINARY.
...
CALL ‘REALIA_EXEC_PROGRAM’
USING PROCESS-HANDLE PROG-NAME COMMAND-LINE
GIVING STATUS-CODE
or
This routine loads and executes the program specified by the file-name given as
an ASCIIZ string in PROG-NAME.
REALIA_EXEC_WAIT - Wait for a process to terminate
CALL ‘REALIA_EXEC_WAIT’
USING PROCESS-HANDLE WAIT-RETURN-CODE
GIVING STATUS-CODE
This routine is used after a call to the REALIA_EXEC_PROGRAM or
REALIA_EXEC_COMMAND routine to wait for completion of a child process.
REALIA_EXEC_DETACH - Detach a child process
01 PROCESS-HANDLE PIC S9(9) BINARY.
01 STATUS-CODE PIC S9(9) BINARY.
CALL ‘REALIA_EXEC_DETACH’ USING PROCESS-HANDLE
GIVING STATUS-CODE.
This routine is used to close a handle.
The return value from the REALIA_EXEC_DETACH function indicates the status
of the close. If the value of STATUS-CODE is zero, then the handle was closed
successfully.
This routine loads and executes the command interpreter. The file name and
location of the command interpreter is determined using the COMSPEC
environment variable.
Regards,
Abhijeet
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For the rest, I'd start with trying to find a friendly support library, or failing that. dig in with the OS system calls directly.
I was going to suggest libcox but went to look, and Symisc Systems mothballed the library. Still good code, but all the doc pages redirect back to the github repo home page now. Borked. Unless you've read some of the old site pages, can't recommend libcox anymore. For anyone willing to dig into a half meg of undocumented amalgamated C sources... https://gnucobol.sourceforge.io/faq/index.html#can-gnucobol-interface-with-libcox
Have good,
Blue
Last edit: Brian Tiffin 2021-04-01
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
CALL 'SYSTEM' for executing any executable.
CALL 'CBL_GC_WAITPID' to wait for a process.
All stock library functions don't use a sub-handle, those that exist use the PID.
It totally should be possible to create either C functions or COBOL programs (calling "C" native functions like the ones hinted at by Ralph) with the same name as the Realia functions. This way you can leave the programs using those unchanged.
If someone writes those functions I'd be happy to have those published in the contrib area (even if those are always win32 specific, at least until someone else creates a more portable version), allowing others porting from Realia to get further more quick.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am looking for alternative functions for the below list of Realia functions. Can you please help?
REALIA_GET_PARM_COUNT - Get number of parameters passed
REALIA_FINDFIRST - Find first file
REALIA_FINDNEXT - Find next file
REALIA_FINDCLOSE - Close the find handle
REALIA_GET_COMMAND_NAME - Return the name of the current program
REALIA_EXEC_PROGRAM - Execute a program
01 PROCESS-HANDLE PIC S9(9) BINARY.
01 PROG-NAME PIC X(260).
01 COMMAND-LINE PIC X(1024).
01 STATUS-CODE PIC S9(9) BINARY.
...
CALL ‘REALIA_EXEC_PROGRAM’
USING PROCESS-HANDLE PROG-NAME COMMAND-LINE
GIVING STATUS-CODE
or
This routine loads and executes the program specified by the file-name given as
an ASCIIZ string in PROG-NAME.
REALIA_EXEC_WAIT - Wait for a process to terminate
01 PROCESS-HANDLE PIC S9(9) BINARY.
01 WAIT-RETURN-CODE PIC S9(9) BINARY.
01 STATUS-CODE PIC S9(9) BINARY.
CALL ‘REALIA_EXEC_WAIT’
USING PROCESS-HANDLE WAIT-RETURN-CODE
GIVING STATUS-CODE
This routine is used after a call to the REALIA_EXEC_PROGRAM or
REALIA_EXEC_COMMAND routine to wait for completion of a child process.
REALIA_EXEC_DETACH - Detach a child process
01 PROCESS-HANDLE PIC S9(9) BINARY.
01 STATUS-CODE PIC S9(9) BINARY.
CALL ‘REALIA_EXEC_DETACH’ USING PROCESS-HANDLE
GIVING STATUS-CODE.
This routine is used to close a handle.
The return value from the REALIA_EXEC_DETACH function indicates the status
of the close. If the value of STATUS-CODE is zero, then the handle was closed
successfully.
REALIA_EXEC_COMMAND - Execute Command Interpreter
01 PROCESS-HANDLE PIC S9(9) BINARY.
01 DOS-COMMAND PIC X(1024).
01 STATUS-CODE PIC S9(9) BINARY.
...
CALL ‘REALIA_EXEC_COMMAND’
USING PROCESS-HANDLE DOS-COMMAND
GIVING STATUS-CODE
This routine loads and executes the command interpreter. The file name and
location of the command interpreter is determined using the COMSPEC
environment variable.
Regards,
Abhijeet
There are some GnuCOBOL functions to implement some of your needs.
"SYSTEM" comes to mind.
Beyond what GnuCOBOL offers, you may have to consider implementing calls to native Windows API entries.
FindFirstFileA
https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findfirstfilea
FindNextFileA function
https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findnextfilea
FindClose function
https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-findclose
GetCurrentProcess function
https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getcurrentprocess
Having found the handle of the current process you should be able to call other Win APIs to further query the process information structure block.
Ralph
For the first, GET_PARM_COUNT, GnuCOBOL includes a special register, Abhijeet,
NUMBER-OF-CALL-PARAMETERS.https://gnucobol.sourceforge.io/faq/index.html#number-of-call-parameters
For the rest, I'd start with trying to find a friendly support library, or failing that. dig in with the OS system calls directly.
I was going to suggest libcox but went to look, and Symisc Systems mothballed the library. Still good code, but all the doc pages redirect back to the github repo home page now. Borked. Unless you've read some of the old site pages, can't recommend libcox anymore. For anyone willing to dig into a half meg of undocumented amalgamated C sources... https://gnucobol.sourceforge.io/faq/index.html#can-gnucobol-interface-with-libcox
Have good,
Blue
Last edit: Brian Tiffin 2021-04-01
CALL 'SYSTEM' for executing any executable.
CALL 'CBL_GC_WAITPID' to wait for a process.
All stock library functions don't use a sub-handle, those that exist use the PID.
It totally should be possible to create either C functions or COBOL programs (calling "C" native functions like the ones hinted at by Ralph) with the same name as the Realia functions. This way you can leave the programs using those unchanged.
If someone writes those functions I'd be happy to have those published in the contrib area (even if those are always win32 specific, at least until someone else creates a more portable version), allowing others porting from Realia to get further more quick.