/*:VRX _RxFindLines */ _rxfindlines: Procedure /* find a phrase in a file and return the line number, line, and all remmed out lines containing the phrase */ Parse Arg phrase, file found_line_no = 0 found_line = '' line_rem_no = '' If phrase <> '' & Stream(file, 'c', 'query exists') <> '' Then Do Call Stream file, 'c', 'close' xrc = SysFileSearch(phrase, file, 'lines.', 'N') If xrc = 0 & lines.0 <> 0 Then Do i = 1 To lines.0 Parse Var lines.i line_no line line_test = Strip(Strip(Translate(line), , "'"), , '"') If Abbrev(line_test, 'REM') , | Abbrev(line_test, '/*') , | Abbrev(line_test, ';') Then Do line_rem_no = line_rem_no line_no Iterate i End Else Do found_line_no = line_no found_line = line End End End Return found_line_no found_line '|' Strip(line_rem_no) /*:VRX _RxReadLines */ _rxreadlines: Procedure Expose file_lines. Parse Arg file Call Stream file, 'c', 'open read' file_lines. = '' file_lines.0 = 0 Do i = 1 While Lines(file) > 0 file_lines.i = Linein(file) End file_lines.0 = i Call Stream file, 'c', 'close' Return /*:VRX _RxUpdLine */ _rxupdline: Procedure Expose file_lines. Parse Arg line_no, line, file, action, close xrc = 1 replace = 0 insert = Abbrev(Translate(action), 'I') If \insert Then replace = 1 close = Abbrev(Translate(close), 'C') If file_lines.0 = 0 Then Call _rxreadlines file If replace Then file_lines.line_no = line Else /* insert a new line */ Do Do i = file_lines.0 To (line_no + 1) By -1 j = i + 1 file_lines.j = file_lines.i End j = line_no + 1 file_lines.j = line file_lines.0 = file_lines.0 + 1 End If close Then Do xrc = 0 save_file = SysTempFileName(VRParseFileName( file, "DPN" ) || '.???') buttons.1 = "OK" buttons.2 = "Cancel" buttons.0 = 2 id = VRMessage( VRWindow(), "Ready to rewrite" file, "", "Query", "Buttons.", , ) If id = 1 Then Do ok = VRCopyFile( file, save_file ) If ok Then Do ok = VRDeleteFile( file ) If ok Then Do Call _rxwritelines file xrc = 1 lines.1 = "Updated" file lines.2 = file "was saved as" save_file lines.0 = 2 id = VRMessageStem( VRWindow(), "Lines.", "", "Information", , , ) End Else Do error = VRError() id = VRMessage( VRWindow(), error, "", "Information", , , ) xrc = 0 lines.1 = "Deletion of" file "failed" lines.2 = file "was saved as" save_file lines.0 = 2 id = VRMessageStem( VRWindow(), "Lines.", "", "Information", , , ) End End Else Do error = VRError() id = VRMessage( VRWindow(), error, "", "Information", , , ) xrc = 0 lines.1 = "Unable to copy" file lines.2 = file "should be intact" lines.0 = 2 id = VRMessageStem( VRWindow(), "Lines.", "", "Information", , , ) End End Else Do xrc = 0 id = VRMessage( VRWindow(), "Update of" file "aborted", "", "Information", , , ) End file_lines. = '' file_lines.0 = 0 End Return xrc /*:VRX _RxWriteLines */ _rxwritelines: Procedure Expose file_lines. Parse Arg file Call Stream file, 'c', 'open write' Do i = 1 To file_lines.0 Call Lineout file, file_lines.i End Call Stream file, 'c', 'close' Return