FUNCTION replacechar(tctable, cfield)
CLOSE ALL
USE (tctable)
GO top
SCAN
oldstring = eval(cfield)
newstring1 = STRTRAN(oldstring,'(', '')
newstring2 = strTRAN(newstring1,') ','-')
replace (cfield) WITH newstring2
ENDSCAN
ENDfunc
>Hi everyone:
>
>I think I have an easy one here for anyone willing to help. Unfortunately, I have spent a number of hours on this and I can't make it work.
>
>I have a function to replace two character portions of a field in a table (see below) with two parameters, one a table (tctable), and the other a field (cfield). Unfortunately, when I pass a field name to the function, it either doesn't work (the variable cfield is not valid) or it replaces the value in the field with the name passed to it, ie "cfield". I am not sure how to pass the field name to the function so that the changes are being made to the actual field values.
>
>any suggestions? thanks.
>
>FUNCTION replacechar(tctable, cfield)
>CLOSE ALL
>USE (tctable)
>GO top
>SCAN
>oldstring = 'cfield'
>newstring1 = STRTRAN(oldstring,'(', '')
>newstring2 = strTRAN(newstring1,') ','-')
>replace 'cfield' WITH newstring2
>ENDSCAN
>ENDfunc