× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Paul,

You're right about using two methods, I just wanted to change the underlying code first to see if it would work OK. If so, I'll rip out the current code and put as much as possible into the java.

Here's the RPG service program code:

The classpath is retrieved from a properties file and set, then the JVM is started.

(I've included the prototypes from copysrc so I hope it readk OK.)

H OPTION(*NODEBUGIO:*NOEXPDDS:*SRCSTMT)
H NOMAIN
H THREAD(*SERIALIZE)
H BNDDIR('QC2LE')
‚‚**********************************************************************
‚* O F F I C E D E P O T I N T E R N A T I O N A L
‚* €
‚*˜ ORDER FULFILMENT SYSTEM
‚* €
‚‚**********************************************************************
‚‚* *
‚‚* Program : XML2STM *
‚‚* *
‚‚* Desc : Create Streamfile data from XML data *
‚‚* *
‚‚* Written : Peter Ducie (XPED) *
‚‚* *
‚‚* Date : September 2004 *
‚‚* *
‚‚**********************************************************************
‚‚* Modification History *
‚‚* *
‚‚* Date Project Pgmr Mod# Description *
‚‚* *
‚*********************************************************************
‚* Prototypes...
‚*********************************************************************
‚* Set environment variables...
D PutEnv pr 10I 0 ExtProc('putenv')
D EnvVar * value options(*string)
‚*.....................................................................


‚* public static int ODOF_XML2SQL.createTransformer(byte£] trans)...
D createTrans pr 10i 0 EXTPROC(*JAVA
D :'ODOF_XML2SQL'
D :'createTransformer')
D static
D bytes 255A Varying Const


    ‚* public static int ODOF_XML2SQL.createResult(byte£] trans)...
    D createResult    pr            10i 0 EXTPROC(*JAVA
    D                                     :'ODOF_XML2SQL'
    D                                     :'createResult')
    D                                     static
    D bytes                        255A   Varying Const

‚* public static int ODOF_XML2SQL.createSource(byte£] trans)...
D createSource pr 10i 0 EXTPROC(*JAVA
D :'ODOF_XML2SQL'
D :'createSource')
D static
D bytes 255A Varying Const
‚*.....................................................................


‚* public static int ODOF_XML2SQL.transform()...
D transform_int pr 10i 0 EXTPROC(*JAVA
D :'ODOF_XML2SQL'
D :'transform')
D static
‚*.....................................................................


/if not defined(setErrorNo)
‚* Set global error number...
d setErrorNo pr
d sentErrorNo 5u 0 value
/define setErrorNo
/endif
‚*.....................................................................
d getErrorNo pr 5u 0
‚*.....................................................................


‚* Retrieve error number in 4S, 0 format...
d getErrorNo4S pr 4s 0
d errorNo4S s 4s 0
‚*.....................................................................


‚* Get Message ID's
d getMSGID pr 7a
d sentErrorNo 4s 0 value
‚*.....................................................................


‚* Set XML source file
d setXMLSource pr 10i 0
d xmlPath 255a value
‚*.....................................................................


‚* retrieve XML source file
d getXMLSource pr 255a
‚*.....................................................................


‚* Set XML result file
d setXMLResult pr 10i 0
d resultPath 255a value
‚*.....................................................................


‚* retrieve XML result file
d getXMLResult pr 255a
‚*.....................................................................


‚* set transformer parameters
d setTransformer pr 10i 0
d xsltPath 255a value
‚*.....................................................................


‚* retrieve transformer
d getTransformer pr 255a
‚*.....................................................................


    ‚* perform transformation
    d transform       pr            10i 0
    d xmlPath                      255a   options(*nopass)
    d resultPath                   255a   options(*nopass)
    d xsltPath                     255a   options(*nopass)

‚*.....................................................................
d setClasspath pr
d inputClasspath 65535a varying const
‚*.....................................................................


d getJVM pr 10i 0
‚*.....................................................................


‚* Read a line from the stream file...
d readLine pr 10i 0
d file 10i 0 value
d line * value
d maxLen 10i 0 value
‚*.....................................................................


    ‚* Get default classpath...
    d getDefaultclasspath...
    d                 pr         65535a

    ‚* global error number constants...

    ‚* Error create stream source...
    D E_CREATEXML     C                   3001

    ‚* Error create stream result...
    D E_CREATERES     C                   3002

    ‚* Error create transformer...
    D E_CREATETRN     C                   3003

    ‚* error creating Java classpath...
    D E_NOCLASSPATH   C                   3007

    ‚* error starting JNI or JVM...
    D E_NOJNIJVM      C                   3008

‚* error transforming XML...
D E_TRANSFORM C 3019
‚**********************************************************************


‚* IFS File management definitions...
d/Copy *LIBL/QRPGLECPY,IFS_Open
d/Copy *LIBL/QRPGLECPY,IFS_Read
d/Copy *LIBL/QRPGLECPY,IFS_Write
d/Copy *LIBL/QRPGLECPY,IFS_Close
‚********************************************************************** €


   ‚‚* IFS File variables...
    d fullName        s            512a
    d fileName        s            512a
    d file            s             10i 0

‚‚* IFS File Constants...
d ##CCSID c Const(32)
d ##Null c Const(X'00')
d ##FILE_CCSID s 10i 0 Inz(819)
‚*.....................................................................
‚* JVM/JNI section...
‚*.....................................................................
D/define OS400_JVM_12
D/copy qsysinc/qrpglesrc,jni


    ‚* JNI environment pointer...
    D env             s               *
    D g_jnienv        s               *   inz(*null)

    ‚* get the JNI environment...
    D getJniEnv       pr              *
    D   inputOpts                65535a   varying const options(*nopass)

    ‚* Start the JVM...
    D startJvm        pr              *
    D   inputOpts                65535a   varying const options(*nopass)

    D attachJvm       pr              *
    D getClasspath    pr         65535a   varying
    D cvtToAscii      pr         65535a   varying
    D   ebcdic                   65535a   varying const

    ‚* Free single object...
    D freeJavaObject  PR
    D  env                            *   const
    D  javaObject                     O   CLASS(*JAVA:'java.lang.Object')
    D                                     value

    ‚* Begin a group of objects...
    D beginObjGroup   PR
    D  env                            *   const
    D  capacity                     10I 0 value

    ‚* End a group of objects...
    D endObjGroup     PR
    D  env                            *   const

‚* Destroy JVM...
D destroyJVM PR 10I 0
‚*..................................................................... €


    ‚* Current state...
    D currentXML      s            255a
    D currentResult   s            255a
    D currentXSLT     s            255a

‚* Program variables...
D DB2_rtcd s 20a
D CP_rtcd s 10i 0
‚*..................................................................... €
d errNo s 5u 0


‚*.....................................................................
‚* free Java Object...
‚*.....................................................................
p freeJavaObject B
D freeJavaObject PI
D env * const
D javaObject O CLASS(*JAVA:'java.lang.Object')
D value
‚*.....................................................................
/free


      JNIENV_P = env;

      If javaObject = *null or JNIEnv_P = *null;
        return;
      endif;

      DeleteLocalRef (JNIEnv_P:javaObject);

/end-free
‚*.....................................................................
p freeJavaObject E
‚*.....................................................................


‚*.....................................................................
‚* begin object group...
‚*.....................................................................
P beginObjGroup B
D beginObjGroup PI
D env * const
D capacity 10I 0 value
D rc s 10I 0
‚*.....................................................................
/free


      JNIENV_P = env;
      rc = pushLocalFrame (JNIENV_P : capacity);

/end-free
‚*.....................................................................
p beginObjGroup E
‚*.....................................................................


‚*.....................................................................
‚* End a group of objects...
‚*.....................................................................
p endObjGroup B
D endObjGroup PI
D env * const
D rc s 10I 0
D refobject s O CLASS(*JAVA:'java.lang.Object')
D newobject s O CLASS(*JAVA:'java.lang.Object')
‚*.....................................................................
/free


      JNIENV_P = env;
      refObject = *null;
      newObject = popLocalFrame (JNIENV_P : refObject);

/end-free
‚*.....................................................................
p endObjGroup E
‚*.....................................................................



‚*.....................................................................
‚* getJniEnv - attach-to or start the JVM
‚*
‚* Parameters:
‚* 1. inputOpts - string of options separated by whatever the
‚* last character in the string is.
‚* For example
‚* -Djava.pool.size=800;-Dcompile=none;
‚* - ignored if the JVM is already started
‚* - classpath is taken from the CLASSPATH environment
‚* variable
‚* Sample calls:
‚* env = getJniEnv() // take the defaults
‚* env = getJniEnv('-Djava.poolsize=800;'
‚* + '-Dcompile=none;') // specify 2 options
‚* env = getJniEnv('-Djava.poolsize=800!'
‚* + '-Dcompile=none!') // use ! as separator
‚*.....................................................................
P getJniEnv b export
‚*.....................................................................
D getJniEnv pi *
D inputOpts 65535a varying const options(*nopass)
D env s * inz(*null)
‚*.....................................................................
/free
env = attachJvm();
if (env = *null);
if %parms() = 0
or %len(inputOpts) = 0;
env = startJvm();
else;
env = startJvm(inputOpts);
endif;
endif;


      g_jnienv = env;
      return env;

/end-free
‚*.....................................................................
P getJniEnv e
‚*.....................................................................


‚*.....................................................................
‚* startJvm - try to start the JVM
‚*
‚* Parameters:
‚* 1. inputOpts - string of options separated by whatever the
‚* first character in the string is
‚* - ignored if the JVM is already started
‚*.....................................................................
P startJvm b
D startJvm pi *
D inputOptsP 65535a varying const options(*nopass)
D initArgs ds likeds(JavaVMInitArgs)
D options ds likeds(JavaVMOption) occurs(10)
D jvm s like(JavaVM_p)
D env s like(JNIENV_p) inz(*null)
D rc s 10I 0
D len s 10I 0
D prefix s 100a varying
D pOptions s * inz(%addr(options))
D i s 10I 0
D classpath S 65535a varying


‚* For handling the input options...
D splitChar s 1a
D pos s 10I 0
D nextPos s 10I 0
D inputOpts s 65535a varying
D inputOptsPtr s *
D freeThisOccur s n dim(%elem(options)) inz(*off)
‚*.....................................................................
/free
monitor;


          initArgs = *allx'00';
          JNI_GetDefaultJavaVMInitArgs (%addr(initArgs));
          initArgs.version = JNI_VERSION_1_2;

          //‚Add classpath option...
          classpath = getClasspath();

          //‚If classpath is blank, retrieve default classpath...
          if classpath = *blanks;
            setClasspath(getDefaultClasspath());
            classpath = getClasspath();
          endif;

          if (%len(classpath) > 0);
             initArgs.nOptions = initArgs.nOptions + 1;
             %occur(options) = initArgs.nOptions;
             freeThisOccur(initArgs.nOptions) = *on;
             options = *allx'00';
             prefix = '-Djava.class.path=:';
             len = %len(prefix) + %len(classpath) + 1;
             options.optionString = %alloc (len);
             %str(options.optionString : len) = cvtToAscii(prefix)
                                              + cvtToAscii(classpath);
          endif;

          // add any other options that were passed in...
          if  %parms > 0
          and %len(inputOptsP) > 0;
             inputOpts = cvtToAscii(inputOptsP);
             inputOptsPtr = %addr(inputOpts) + 2;
             splitChar = %subst(inputOpts : %len(inputOpts) : 1);
             pos = 1;
             dow pos <= %len(inputOpts);
                nextPos = %scan(splitChar : inputOpts : pos);
                len = nextPos - pos;
                %subst(inputOpts : nextPos : 1) = x'00';
                initArgs.nOptions = initArgs.nOptions + 1;
                %occur(options) = initArgs.nOptions;
                options = *allx'00';
                options.optionString = inputOptsPtr + pos - 1;
                pos = nextPos + 1;
             enddo;
          endif;

          if initArgs.nOptions > 0;
             initArgs.options = pOptions;
          endif;

          rc = JNI_CreateJavaVM (jvm : env : %addr(initArgs));
          if (rc <> 0);
             env = *null;
          endif;

       on-error;
          env = *null;
       endmon;

// free any storage allocated for the options...
for i = 1 to initArgs.nOptions;
if (freeThisOccur(i));
%occur(options) = i;
dealloc(n) options.optionString;
endif;
endfor;
return env;
/end-free
&#130;*.....................................................................
P startJvm e
&#130;*.....................................................................


&#130;*.....................................................................
&#130;* attachJvm - try to attach to the JVM
&#130;*.....................................................................
P attachJvm b
&#130;*.....................................................................
D attachJvm pi *
D attachArgs ds likeds(JavaVMAttachArgs)
D jvm s like(JavaVM_p) dim(1)
D nVms s like(jsize)
D env s * inz(*null)
D rc s 10I 0
&#130;*.....................................................................
/free
monitor;
rc = JNI_GetCreatedJavaVMs(jvm : 1 : nVms);
if (rc <> 0);
return *null;
endif;
if (nVms = 0);
return *null;
endif;
JavaVM_P = jvm(1);
attachArgs = *allx'00';
attachArgs.version = JNI_VERSION_1_2;
rc = AttachCurrentThread (jvm(1) : env : %addr(attachArgs));
if (rc <> 0);
env = *null;
endif;
on-error;
env = *null;
endmon;
g_jnienv = env;
return env;
/end-free
&#130;*.....................................................................
P attachJvm e
&#130;*.....................................................................


&#130;*.....................................................................
&#130;* Destroy the JVM...
&#130;*.....................................................................
P destroyJVM B
D destroyJVM PI 10I 0
D rc S LIKE(jint)
D rpgRc S N
D jvm S * DIM(1)
D env S *
D bufLen S LIKE(jsize) INZ(%elem(jvm))
D nVMs S LIKE(jsize)
&#130;*.....................................................................
/free


      // See if there&#146;s a JVM started...
      rc = JNI_GetCreatedJavaVMs (jvm : bufLen : nVMs);

      // If JVM is started...
      if (rc = 0 and nVMs > 0);
        JavaVM_P = jvm(1);
        rc = DestroyJavaVM (jvm(1));
      endif;

      return rc;

/end-free
&#130;*.....................................................................
P destroyJVM E
&#130;&#130;*.....................................................................


&#130;&#130;*.....................................................................
&#130;* getClasspath - retreive the CLASSPATH environment variable...
&#130;&#130;*.....................................................................
P getClasspath B
D getClasspath PI 65535A varying
* See QSYSINC/H
D Qp0zGetEnvNoInit...
D PR * extproc('Qp0zGetEnvNoInit')
D name * value options(*string)
D envVarP S *
&#130;&#130;*.....................................................................
/free
envvarP = Qp0zGetEnvNoInit('CLASSPATH');
if (envvarP = *NULL);
return '';
else;
return %str(envvarP : 65535);
endif;
/end-free
&#130;&#130;*.....................................................................
P getClasspath E
&#130;&#130;*.....................................................................



&#130;&#130;*.....................................................................
&#130;* cvtToAscii - convert from EBCDIC to ASCII...
&#130;&#130;*.....................................................................
P cvtToAscii B
D cvtToAscii PI 65535A varying
D input 65535A const varying
D QDCXLATE PR extpgm('QDCXLATE')
D len 5P 0 const
D cnvData 65535A options(*varsize)
D cnvTbl 10A const
D cnvLib 10A const
D retval S like(input)
D retvalRef S 1A based(retvalPtr)
&#130;&#130;*.....................................................................
/free
retval = input;
retvalPtr = %addr(retval) + 2; // set ptr after the length part
QDCXLATE(%len(retval): retvalRef : 'QASCII': 'QSYS');
return retval;
/end-free
&#130;&#130;*.....................................................................
P cvtToAscii E
&#130;&#130;*.....................................................................


&#130;&#130;*.....................................................................
p setErrorNo b
&#130;&#130;*.....................................................................
d setErrorNo pi
d sentErrorNo 5u 0 value
&#130;*....................................................................
&#130;* Set the global error number...
&#130;*....................................................................


     /free
              errNo = sentErrorNo;

/end-free
&#130;*.....................................................................
p setErrorNo e
&#130;*.....................................................................
p getErrorNo b export
d getErrorNo pi 5u 0
&#130;*.....................................................................
&#130;* Return the global error number...
&#130;*.....................................................................
/free


return errNo;
/end-free
&#130;*.....................................................................
p getErrorNo e
&#130;&#130;*.....................................................................
p setXMLSource b export
&#130;&#130;*.....................................................................
d setXMLSource pi 10i 0
d xmlPath 255a value
&#130;*.....................................................................
/free


       getJVM();

       //&#130;Create xml stream source...
       monitor;
       if createSource(xmlPath) < 0;
           setErrorNo(E_CREATEXML);
           return -1;
         endif;
       on-error;
         setErrorNo(E_CREATEXML);
         return -1;
       endmon;

       currentXML = xmlPath;
       return 0;

/end-free
&#130;*.....................................................................
p setXMLSource e
&#130;*.....................................................................


&#130;&#130;*.....................................................................
p getXMLSource b export
&#130;&#130;*.....................................................................
d getXMLSource pi 255a
&#130;*.....................................................................
/free


       //&#130;Return current XML document...
       return currentXML;

/end-free
&#130;*.....................................................................
p getXMLSource e
&#130;*.....................................................................


&#130;&#130;*.....................................................................
p setXMLResult b export
&#130;&#130;*.....................................................................
d setXMLResult pi 10i 0
d resultPath 255a value
&#130;*.....................................................................
/free


       getJVM();

       //&#130;Create result source...
       monitor;
       if createResult(resultPath) < 0;
           setErrorNo(E_CREATERES);
           return -1;
         endif;
       on-error;
         setErrorNo(E_CREATERES);
         return -1;
       endmon;

       currentResult = resultPath;
       return 0;

/end-free
&#130;*.....................................................................
p setXMLResult e
&#130;*.....................................................................



&#130;&#130;*.....................................................................
p getXMLResult b export
&#130;&#130;*.....................................................................
d getXMLResult pi 255a
&#130;*.....................................................................
/free


       //&#130;Return current XML result document...
       return currentResult;

/end-free
&#130;*.....................................................................
p getXMLResult e
&#130;*.....................................................................


&#130;&#130;*.....................................................................
p setTransformer b export
&#130;&#130;*.....................................................................
d setTransformer pi 10i 0
d xsltPath 255a value
&#130;*.....................................................................
/free


       getJVM();

       //&#130;Create transformer...
       monitor;
       if createTrans(xsltPath) < 0;
           setErrorNo(E_CREATETRN);
           return -1;
         endif;
       on-error;
         setErrorNo(E_CREATETRN);
         return -1;
       endmon;

       currentXSLT = xsltPath;
       return 0;

/end-free
&#130;*.....................................................................
p setTransformer e
&#130;*.....................................................................


&#130;&#130;*.....................................................................
p getTransformer b export
&#130;&#130;*.....................................................................
d getTransformer pi 255a
&#130;*.....................................................................
/free


       //&#130;Return current XSLT document...
       return currentXSLT;

/end-free
&#130;*.....................................................................
p getTransformer e
&#130;*.....................................................................



&#130;&#130;*.....................................................................
p transform b export
&#130;&#130;*.....................................................................
d transform pi 10i 0
d xmlPath 255a options(*nopass)
d resultPath 255a options(*nopass)
d xsltPath 255a options(*nopass)
&#130;*.....................................................................
/free


       //&#130;If XML file passed, set it...
       if %parms > 0 and xmlPath <> *blanks;
         if setXMLSource(xmlPath) < 0;
           return -1;
         endif;
       endif;

       //&#130;If result file passed, set it...
       if %parms > 1 and resultPath <> *blanks;
         if setXMLResult(resultPath) < 0;
           return -1;
         endif;
       endif;

       //&#130;If transformer passed, set transformer...
       if %parms > 2 and xsltPath <> *blanks;
         if setTransformer(xsltPath) < 0;
           return -1;
         endif;
       endif;

       //&#130;Transform...
       monitor;
         if transform_int() < 0;
           setErrorNo(E_TRANSFORM);
           return -1;
         endif;
       on-error;
         setErrorNo(E_TRANSFORM);
         return -1;
       endmon;

       return 0;

/end-free
&#130;*.....................................................................
p transform e
&#130;*.....................................................................


&#130;*.....................................................................
&#130;* Retrieve error number in 4S, 0 format...
&#130;*.....................................................................
p getErrorNo4S b export
d getErrorNo4S pi 4s 0


d errorNo4S s 4s 0
&#130;*.....................................................................
&#130;* Return the global error number in 4S, 0 format...
&#130;*.....................................................................


     /free
      if errNo  >= 9999;
       errorNo4S = 9999;
      else;
       errorNo4S = errNo;
      endif;

return errorNo4S;
/end-free
&#130;*.....................................................................
p getErrorNo4S e
&#130;*.....................................................................


&#130;*.....................................................................
&#130;* Retrieve the Message ID for the specified error number...
&#130;*.....................................................................
p getMSGID b export
d getMSGID pi 7a
d sentErrorNo 4s 0 value
&#130;*.....................................................................
&#130;* Set the global error number...
&#130;*.....................................................................


    &#130;* Set message prefix ...

     /free

       return  ('JVO' + %editc(sentErrorNo:'X'));

/end-free
&#130;*.....................................................................
p getMSGID e
&#130;*.....................................................................
&#130;*.....................................................................
&#130;* Retrieve the classpath
&#130;*.....................................................................
p setClasspath b export
d setClasspath pi
d inputClasspath 65535a varying const


     /free

        monitor;
        //&#130;Set classpath...
         CP_rtcd = putenv('CLASSPATH=' + %trim(inputClasspath));
        on-error;
        setErrorNo(E_NOCLASSPATH);
        endmon;

        return;

/end-free
&#130;*.....................................................................
p setClasspath e
&#130;*.....................................................................


&#130;*.....................................................................
p getJVM b export
d getJVM pi 10i 0
&#130;*.....................................................................


     /free

        monitor;
        //&#130;Get the current environment (or start a new JVM)...
        env = getJniEnv('-Djava.version=1.4;');
        on-error;
        setErrorNo(E_NOJNIJVM);
        return -1;
        endmon;

        return 0;

/end-free
p getJVM e
&#130;*.....................................................................


&#130;*.....................................................................
p getDefaultclasspath...
p b export
d getDefaultclasspath...
d pi 65535a


&#130;* Prototype variables... &#128;
d idx s 10i 0
d classpath s 65535a varying
d propFile s 255a inz(*blanks)
D line s 1024a
D lineLen s 10i 0 inz(%size(line))
D dataLen s 10i 0
D equalPos s 10i 0
&#130;*.....................................................................


     /free

        //&#130;Set properties file name...
        propFile = '/QIBM/UserData/XML2SQL.properties';

        //&#130;Open the IFS file...
        fullName = %TrimR(propFile) + ##Null;
        file = IFS_Open(%addr(fullName):##TextData + ##ReadWrite);


//&#130;If unable to open file, return blanks... if file < 0; return *blanks; endif;

        dow dataLen >= 0;

          //&#130;Read a line from the IFS file...
          dataLen = readLine(file:%addr(line):lineLen);

          //&#130;If EOF or error, leave loop...
          if dataLen < 0;
            leave;
          endif;

          //&#130;Ignore comment lines...
          if %subst(line:1:1) = '#';
            iter;
          endif;

         //&#130;Ignore lines that do not have '='...
         equalPos = %scan('=':line:1);
         if equalPos = 0;
           iter;
          endif;

//&#130;If property is CLASSPATH property, retrieve it and leave loop...
if %subst(line:1:equalPos-1) = 'CLASSPATH';
classpath = %trim(%subst(line:equalPos+1
:lineLen-equalPos));
leave;
endif;
enddo;


       //&#130;Close the file...
       IFS_Close(file);

       //&#130;Return the classpath...
       return classpath;

/end-free
&#130;*.....................................................................
p getDefaultclasspath...
p e
&#130;*.....................................................................



&#130;********************************************************************** &#128;
&#130;* readLine - Read a line from the file...
&#130;*************************************************************************
p readLine b
d readLine pi 10i 0
d file 10i 0 value
d line * value
d lineLen 10i 0 value


&#130;* Prototype variables... &#128;
d rc s 10i 0 inz(*zero)
D ch s 1a inz(*blanks)
D tempLineLen s 10i 0 inz(*zero)
D tempLine s 32766a based(line)
D carriageReturn c const(X'0D')
D lineFeed c const(X'25')
&#130;*************************************************************************


    &#130;* Initialise temporary field, based on passed pointer...
    c                   eval      %subst(tempLine:1:lineLen) = *blanks

    &#130;* Read a line from the IFS file (byte-by-byte)...
    c                   do        *hival
    c                   eval      rc = IFS_Read( file: %addr(ch) : 1)

    &#130;* If EOF or an error occurred...
    c                   if        rc < 1

    &#130;* If there is data on the line, return line length...
    c                   if        tempLineLen > 0
    c                   return    tempLineLen

    &#130;* If there is no data on the line, return error...
    c                   else
    c                   return    -1
    c                   endif
    c                   endif

    &#130;* Once a line-feed has been reached, return line length...
    c                   if        ch = lineFeed
    c                   return    tempLineLen
    c                   endif

    &#130;* Include all non-carriage return characters in current line...
    c                   if        ch <> carriageReturn
    c                   eval      tempLineLen += 1
    c                   eval      %subst(tempLine:tempLineLen:1) = ch
    c                   endif

    &#130;* If reached length of passed pointer, leave...
    c                   if        tempLineLen = lineLen
    c                   leave
    c                   endif

    c                   enddo

&#130;* Return qualified job description... &#128;
c return tempLineLen


&#130;*********************************************************************
p readLine e
&#130;*************************************************************************


Cheers

Larry



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.