[Info-vax] FIND/REPLACE

Henry Crun mike at rechtman.com
Mon Mar 6 06:23:14 EST 2023


On 06/03/2023 8:53, walter.... at gmail.com wrote:
<..snipped...>

> Robert A. Brooks schrieb am Donnerstag, 2. März 2023 um 03:08:58 UTC+1:
>> On 3/1/2023 1:34 AM, walter.... at gmail.com wrote:
  <...end snip...>

I've been using a simple FIND/REPLACE of my own for several decades now.
Not especially clever, but works for me.
I'm sure it can be debugged and/or improved  (KISS...)

at DCL level:
$ REPL*ACE == "Edit/TPU/NOsection/Command=Disk:[wherever]rep.tpu"
                                           ^^^^^^^^^^^^^^^                 <== edit here

<code rep.tpu>
PROCEDURE global_search_replace( str1,str2 )
LOCAL src_range, replace_count

ON_ERROR
  msg_txt := FAO(" Completed !UL replacement!%S " , replace_count );
  MESSAGE(msg_txt);
  RETURN;
ENDON_ERROR;

replace_count := 0;
LOOP
   src_range := SEARCH( str1,FORWARD );
   ERASE( src_range );
   POSITION( END_OF( src_range ) );
   COPY_TEXT( str2 );
   replace_count := replace_count + 1;
ENDLOOP;
ENDPROCEDURE;

file_spec := GET_INFO( COMMAND_LINE,"file_name" );
next_file := "";
IF file_spec = ""
THEN
	MESSAGE( "You did not enter an input file-spec (wildcards allowed)" ) ;
	EXIT ;
EndIf ;

in_str := READ_LINE ( " Input_String :" ) ;
MESSAGE(" ");
out_str := READ_LINE ( "Output_String :" ) ;
Loop
	next_file := File_Search (file_spec);
	Exitif next_file = "";
	msg_txt := FAO( "Working on !AS" , next_file );
	MESSAGE ( msg_txt ) ;
	main_buffer := CREATE_BUFFER( "main",next_file ) ;
	POSITION( BEGINNING_OF( main_buffer ) ) ;
	global_search_replace( in_str,out_str ) ;
	WRITE_FILE ( main_buffer ) ;
	DELETE ( main_buffer ) ;
	MESSAGE("------------------");
	MESSAGE(" ");
Endloop ;
Exit ;
!
</code>

Let EDT do the work.

-- 
No Micro$oft products were used in the URLs above, or in preparing this message.
Recommended reading: http://www.catb.org/~esr/faqs/smart-questions.html#befor




More information about the Info-vax mailing list