Welcome Guest, you are in: Login

Fruit Of The Shed

Navigation (MMBasic)






Search the wiki

»


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,d,e
		Local r$,x$
		z=1:d=Len(c$):e=Len(b$):r$=a$
		Do
			z=Instr(z,r$,b$)
			If z=0 Then Exit Do
			x$=Left$(r$,z-1)
			r$=x$+c$+Mid$(r$,z+e)
			z=Len(x$)+d
		Loop
		Replace$=r$
	End FunctionN