Basket #55902 (Version: ) - Miva - Snippets
<MvFUNCTION NAME = "Replace" PARAMETERS = "string, search, replace, start VAR" STANDARDOUTPUTLEVEL = ""> <MvCOMMENT> <MvASSIGN NAME="g.string" VALUE="{ 'Now is the time for all good men to come to the aid of their nation.' }"> <MvEVAL EXPR="{ Replace(g.string, 'nation', 'country', g.start) }"><br> <MvEVAL EXPR="{ g.start }"> </MvCOMMENT> <MvASSIGN NAME = "l.savestring" VALUE = "{ l.string }"> <MvIF EXPR = "{ l.start LT 1 }"> <MvASSIGN NAME = "l.start" VALUE = "{ 1 }"> </MvIF> <MvIF EXPR = "{ l.start GT 1 }"> <MvASSIGN NAME = "l.left" VALUE = "{ substring(l.string,1,l.start -1) }"> </MvIF> <MvASSIGN NAME = "l.string" VALUE = "{ substring(l.string,l.start,len(l.string)) }"> <MvASSIGN NAME = "l.posn" VALUE = "{ l.search IN l.string }"> <MvIF EXPR = "{ l.posn GT 1 }"> <MvASSIGN NAME = "l.left" VALUE = "{ l.left $ substring(l.string,1,(l.posn -1)) }"> <MvASSIGN NAME = "l.string" VALUE = "{ substring(l.string,l.posn,len(l.string)) }"> </MvIF> <MvIF EXPR = "{ (l.search IN l.string ) EQ 1 }"> <MvASSIGN NAME = "l.right" VALUE = "{ substring(l.string,len(l.search)+1,len(l.string)) }"> <MvASSIGN NAME = "l.start" VALUE = "{ len(l.left $ l.replace) + 1 }"> <MvASSIGN NAME = "l.return" VALUE = "{ l.left $ l.replace $ l.right }"> <MvIF EXPR = "{ l.start GT len(l.return) }"> <MvASSIGN NAME = "l.start" VALUE = "{ 0 }"> </MvIF> <MvELSE> <MvASSIGN NAME = "l.return" VALUE = "{ l.savestring }"> <MvASSIGN NAME = "l.start" VALUE = "{ 0 }"> </MvIF> <MvFUNCRETURN VALUE = "{ l.return }"> </MvFUNCTION>