func init if(linked("StringBuilder")) // add using module sys.add_use('System.Text') // defines an instance of StringBuilder this.setfield('sb', d("StringBuilder")) // initialize properties if(linked("onError")) this.setfield('ex', 'ex' + this.id) end if(linked("doReplace") and (linked("Result") or linked("ToString"))) sys.add_var(this.name, 'StringBuilder') end end end func make_replace(data) return(this.sb && '.Replace(' && d("oldValue") && ', ' && d("newValue") && ')') end func doReplace(data) if(linked("StringBuilder")) linked("onError") ? blk.println('try {').inc() : '' if(linked("Result") or linked("ToString")) blk.println(this.codename, ' = ', make_replace(data), ';') event("onResult", this.codename) else event("onResult", make_replace(data)) end if(linked("onError")) blk.dec().println('} catch(ArgumentException ', this.ex, ') {').inc() event("onError", this.ex + '.Message') blk.dec().println('}') end end end func Result if(linked("StringBuilder")) if(linked("doReplace")) return(this.codename) else return(make_replace()) end end end func ToString if(linked("StringBuilder")) if(linked("doReplace")) return(this.codename + '.ToString()') else return(make_replace() && '.ToString()') end end end