home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
epm603b.zip
/
EPMSMP.ZIP
/
GLOBCHNG.E
< prev
next >
Wrap
Text File
|
1994-11-15
|
3KB
|
120 lines
compile if not defined(SMALL) -- If SMALL not defined, then being separately compiled.
define INCLUDING_FILE = 'GLOBCHNG.E'
const
tryinclude 'MYCNF.E' -- the user's configuration customizations.
compile if not defined(SITE_CONFIG)
const SITE_CONFIG = 'SITECNF.E'
compile endif
compile if SITE_CONFIG
tryinclude SITE_CONFIG
compile endif
const
compile if not defined(SETSTAY)
SETSTAY = 0
compile endif
compile if not defined(NLS_LANGUAGE)
NLS_LANGUAGE = 'ENGLISH'
compile endif
include NLS_LANGUAGE'.e'
defmain -- External modules always start execution at DEFMAIN.
'globchng' arg(1)
compile if EVERSION >= 6
EA_comment 'This defines the GLOBCHNG command; it can be linked, or executed directly.'
compile endif
compile endif -- not defined(SMALL)
defc globchng, globalchange
universal lastchangeargs, default_search_options
compile if SETSTAY='?'
universal stay
compile endif
/* Insert default_search_options just before supplied options (if any) */
/* so the supplied options will take precedence. */
user_options=''
change_args=strip(arg(1),'L') /* Delimiter = 1st char, ignoring leading spaces. */
delim=substr(change_args,1,1)
p=pos(delim, change_args, 2) /* find last delimiter of 2 or 3 */
if p then
p=pos(delim, change_args, p+1) /* find last delimiter of 2 or 3 */
if p>0 then
user_options=substr(change_args, p+1)
change_args=substr(change_args,1,p-1)
endif
else
sayerror NO_REP__MSG
return
endif
if verify(upcase(default_search_options),'M','M') then
user_options = 'A'user_options
endif
change_args=change_args || delim || default_search_options || user_options
backwards = 0
p1 = lastpos('-', default_search_options || user_options)
if p1 then
if p1 > lastpos('+', default_search_options || user_options) then
backwards = 1
endif
endif
reverse = 0
p1 = lastpos('R', upcase(default_search_options || user_options))
if p1 then
if p1 > lastpos('F', upcase(default_search_options || user_options)) then
reverse = 1
endif
endif
/* Remember our current file so we don't search forever. */
getfileid StartFileID
change_count = 0
loop
/* Include this refresh if you like to see each file as it's */
/* searched. Causes too much screen flashing for my taste, */
;; refresh
/* Start from top of file, save current posn in case no match. */
call psave_pos(save_pos)
if backwards then
bottom
if reverse then
end_line
else
begin_line
endif
else
0
endif
'xcom c' change_args
if rc=0 then
change_count = change_count + 1
compile if SETSTAY='?'
if stay then
compile endif
compile if SETSTAY
call prestore_pos(save_pos)
compile endif
compile if SETSTAY='?'
endif
compile endif
else
/* no match in file - restore file location */
call prestore_pos(save_pos)
endif
nextfile
getfileid fileid
if fileid=StartFileID then
leave
endif
endloop
if change_count = 1 then
files = 'file.'
else
files = 'files.'
endif
sayerror 'String changed in' change_count files