Code Example: Building a Memory File with mf_rowrpl()

Array fstring[ ] contains pointers to strings, some of which contain embedded newlines. The array contains a NULLP after the last string pointer. The following function shows how these strings can be transferred to a previously defined but empty memory file.

Because no memory file viewing capabilities are used in this module, you only need to include the system header file vv_sys.h.

#include <vv_sys.h> 

UCHAR *fstring[] = 

{

    "This is a two line\nstring.",

    "This is a simple string.",

    NULLP 

};

int excode(mfp)

MFILEPTR mfp;

{ 

    int mf_row, retval;

 
    mf_row = 0;
/* Initialize counter variable



*/
    while(fstring[mf_row]) 

    { 

        if ((retval = mf_rowrpl(fstring[mf_row],    

                    APPEND_ROW, mfp)) <= 0)
 
            break;
/* Error return
*/
        mf_row++;

    }
/* Next string
*/
    return(retval); 

} 
   

In this example, an immediate return of -1 is made on a return of -1 by mf_rowrpl(), guarding against a line segment longer than the maximum columns specified for the memory file.


Home Contents Previous Next