The following function will copy a long string onto multiple rows, if necessary. This code will operate correctly only if the string does not contain embedded newlines.
|
||
|
|
|
|
|
|
|
||
If the string is not fully copied by a call to mf_rowrpl(), the string pointer is advanced by the number of characters copied, the file row number is incremented, and mf_rowrpl() is called again. The string pointer is advanced by the value of mfp->fmaxcol, the number of characters placed on the file row when the string length exceeds the limit.
The while loop will exit when the return value is greater than zero, meaning that the copy has been successfully completed.
Note: If the string is being appended to a memory file, rather than replacing existing lines, the code can be made simpler by using the #defined parameter APPEND_ROW in the call to mf_rowrpl(). The affected lines would read:
|