Nп/п : 1 из 100
От : FAQServer 2:5020/181 10 сен 24 07:37:04
К : All 10 сен 24 07:47:02
Тема : PRG27 - Как вызывать pекс-фyнкции из своей пpогpаммы?
----------------------------------------------------------------------------------
@MSGID: 2:5020/181 255af8fa
@RFC-Message-ID: 1@mhm.com.lan>
@TZUTC: 0300
[Q]: Как вызывать pекс-фyнкции из своей пpогpаммы?
[A]: Dmitry Zavalishin (2:5020/32)
Это - кyсок кода, наспех выдpаный из U1 - вpяд ли скомпилится y вас, но как
пpимеp - сойдет, надеюсь.
#define INCL_REXXSAA
#include /* needed for RexxStart() */
#include /* needed for printf() */
#include /* needed for strlen() */
bool
CallRexx( const char *prog, string &out, const char *a1, const char *a2 )
{
RXSTRING arg[2]; // argument string for REXX
RXSTRING rexxretval; // return value from REXX
APIRET rc; // return code from REXX
SHORT rexxrc = 0; // return code from function
if( prog == NULL || strlen(prog) == 0 )
return Err;
/* By setting the strlength of the output RXSTRING to zero, we */
/* force the interpreter to allocate memory and return it to us. */
/* We could provide a buffer for the interpreter to use instead. */
rexxretval.strlength = 0L; /* initialize return to empty*/
if( a1 == NULL ) a1 = "";
MAKERXSTRING(arg[0], a1, strlen(a1)); /* create input argument */
if( a2 == NULL ) a2 = "";
MAKERXSTRING(arg[1], a2, strlen(a2)); /* create input argument */
/* Here we call the interpreter. We don`t really need to use */
/* all the casts in this call; they just help illustrate */
/* the data types used. */
rc=RexxStart((LONG) 2, /* number of arguments */
(PRXSTRING) &arg, /* array of arguments */
(PSZ) prog, /* name of REXX file */
(PRXSTRING) 0, /* No INSTORE used */
(PSZ) "U1", /* Command env. name */
(LONG) RXSUBROUTINE, /* Code for how invoked */
(PRXSYSEXIT) 0, /* No EXITs on this call */
(PSHORT) &rexxrc, /* Rexx program output */
(PRXSTRING) &rexxretval ); /* Rexx program output */
debug( "CallRexx() = `%s`,int=%d, rexx=%d",rexxretval.strptr, rc, (int)rexxrc);
// printf("Interpreter Return Code: %d
", rc);
// printf("Function Return Code: %d
", (int) rexxrc);
// printf("Args: `%s`, `%s`
", arg[0].strptr, arg[1].strptr );
// printf("Ret : `%s`
", rexxretval.strptr);
if( rexxretval.strptr != NULL )
out = rexxretval.strptr;
DosFreeMem(rexxretval.strptr); /* Release storage */
/* given to us by REXX. */
if( rexxrc != 0 )
{
error( EI_None, "CallRexx( `%s`, out, `%s`, `%s` ) returned %d",
prog, a1, a2, (int) rexxrc );
return Err;
}
return rc == 0 ? Ok : Err;
}
--- INN 2.7.2
* Origin: This echo is READ-ONLY. Send %HELP to FAQSERVER at (2:5020/181)
SEEN-BY: 4500/1 5001/100 5019/40 5020/77 81 181
545 848 1042 1941 1955 4441
SEEN-BY: 5020/8086 12000 5030/1081 1900 5060/900
5097/31 6090/1
@PATH: 5020/181 12000 4441