#!/usr/local/rexx/rxx /* * write - a program to replace a specified line in a file * * Syntax: call write , , * * is the name of the file to be updated * is the number of the line to be replaced * is the new data to be placed on that line * * * If you wish to invoke write as a function, it should be modified * to perform appropriate testing of return codes from linein() and * lineout() and to return an appropriate value based on the results * of these tests. * * * Modification History: * * 25 Jul 94 twg Initial implementation * * */ parse arg fname, line_num, string do i = 1 to lines(fname) /* for every line in file */ x = linein(fname) /* read a line */ if i \= line_num then queue x /* if not line to be replaced, queue it */ else queue string /* or queue replacement string */ end call lineout fname /* close file */ parse pull y /* get first line */ call lineout fname, y, 1 /* reinitialize file */ do queued() /* do the rest */ parse pull y call lineout fname, y end call lineout fname /* close file */ return