home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Du Jour
/
SoftwareDuJour.iso
/
BUSINESS
/
DBASE
/
DBREP.ARC
/
REPSUB.PRG
< prev
Wrap
Text File
|
1985-10-30
|
1KB
|
35 lines
*** REPSUB.PRG Subroutine to GLOBAL SEARCH AND REPLACE PROGRAM
NFIELD = &MFIELD
* CHECK IF FIELD CONTAINS SINGLE AND/OR DOUBLE QUOTES
DO CASE
** CASE FOR BOTH SINGLE AND DOUBLE QUOTES IN FIELD
CASE '"'$&MFIELD .AND. "'"$&MFIELD
? "Sorry, unable to replace fields containing both single and double quotes."
? "Please edit manually. "
READ
WAIT
MCOUNT = MCOUNT + 1
RETURN
** CASE FOR DOUBLE QUOTES IN FIELD
CASE '"'$&MFIELD
** LPART1 = LENGTH OF FIRST PART OF FIELD TO SAVE
LPART1 = AT('&MTEXT','&NFIELD') - 1
**PART1 = FIRST PART OF FIELD TO STORE
PART1 = SUBSTR('&NFIELD',1,LPART1)
** MSTART2 = START OF SECOND PART OF FIELD TO SAVE
MSTART2 = LPART1 + LMTEXT + 1
** LPART2 = LENGTH OF SECOND PART OF FIELD TO SAVE
LPART2 = LEN('&NFIELD') - MSTART2 + 1
** PART2 = SECOND PART OF FIELD TO STORE
PART2 = SUBSTR('&NFIELD',MSTART2,LPART2)
OTHERWISE
LPART1 = AT("&MTEXT","&NFIELD") - 1
MSTART2 = LPART1 + LMTEXT + 1
LPART2 = LEN("&NFIELD") - MSTART2 + 1
PART1 = SUBSTR("&NFIELD",1,LPART1)
PART2 = SUBSTR("&NFIELD",MSTART2,LPART2)
ENDCASE
REPLACE &MFIELD WITH PART1 + NTEXT + PART2
MCOUNT = MCOUNT + 1
RELEASE NFIELD