(RPG) APIs provided in LongRange to aid you in common tasks

Please mark posts as being for RPG or RDMLX (LANSA) developers.
To subscribe by email, display this forum, scroll to the end and select ‘Subscribe Forum’.
Post Reply
Paul

(RPG) APIs provided in LongRange to aid you in common tasks

Post by Paul »

LongRange includes some simple to use APIs that help you perform common tasks.
For example – writing a file out into the IFS ................

Code: Select all

   // Open as UTF-8 using standard IBM i file open/reopen technique.
    //  Local.RetCode is declared asa 10I00 (integer) field.
    //  The open is actually done by the ILE C library 'fopen' function.
    //  See http://publib.boulder.ibm.com/infocenter/iadthelp/v6r0/index.jsp
    //          ?topic=/com.ibm.etools.iseries.langref.doc/rzan5mst115.htm
    //  for what all the second parameter options are. 

    Local.RetCode = LRNG_FileOpen('/TestFile.html' : 'w,o_ccsid=1208');

    If (Local.RetCode <> 1);

      // The open has failed. In fact all LRNG_file operations
      // will return a 1 if they complete normally - otherwise
      // they return a value < 1. Running with LRNG_SystemTraceOn()
      // will normally trace out the exact IBM i errno or message.

    Else;

     // Close and reopen so that all future data written is converted from 
      // current job’s CCSID

     LRNG_FileClose();
     LRNG_FileOpen('/TestFile.txt': 'w,o_ccsid=0');

      // Write out data

     LRNG_FileWrite('<html><head></head><body>':0);

         LRNG_FileWrite('<div>Hello World</div>':0);
         LRNG_FileWrite('<div>Hello World Again</div>':0);
         LRNG_FileWrite('<div>Hello World Finally</div>':0);

      LRNG_FileWrite('</body><html>':0);

     // Close the file

      LRNG_FileClose();

    Endif;
Post Reply