Page History: REPLACE$ Function (VB work-a-like)
Compare Page Revisions
Page Revision: 2016/12/17 19:41
Returns a string in which all occurrences of one specified substring have been replaced with another.
Syntax:
Replace$(expression, find, replacewith)
Example:
fred$=Replace$(Date$,"/","-") 'replaces all / in the date with -
Code:
FUNCTION Replace$(a$,b$,c$)
LOCAL INTEGER z
LOCAL STRING x$,y$
z=1
DO
z=INSTR(z,a$,b$)
IF z=0 THEN EXIT DO
x$=LEFT$(a$,z-1)
y$=MID$(a$,z+LEN(b$))
a$=x$+c$+y$
z=LEN(x$)+LEN(c$)
LOOP
Replace$=a$
END FUNCTION