nawtykitty
IS-IT--Management
With some help from various other users, I have come up with the following script to remove hyphens from a social security field called P_SSN in a DBase table (the name of the process script is noHyphen):
;*********code for a script
method run(var eventInfo Event)
cmProcessMain()
endMethod
;******************************
method cmProcessMain()
var
strOrigSS,strNewSS string
tc tcursor
endvar
tbl = ":work:abraxport.dbf"
if not tc.open(tbl) then
errorshow("open tc error"
return
endif
tc.edit()
scan tc :
strOrigSS = tc."OrigSsFieldname"
if cmNoHyphen(strOrigSS,strNewSS)
then tc."NewSsFieldname" = strNewSS
else
msgInfo("Data odd : ",strOrigSS)
endif
endscan
tc.endedit()
tc.close()
endMethod
;*********************************
method cmNoHyphen(strOrig string, var strNew string) logical
;111-22-3333
; should be 9 + 2 = 11 long
if strOrig.size() <> 11 or
strOrig.substr(4,1)<> "-" or
strOrig.substr(7,1)<> "-"
then
return(false)
endif
stNew = strOrig.substr(1,3) + ; 111
strOrig.substr(5,2) + ; 22
strOrig.substr(8,4) ; 3333
return(true)
endMethod
I get an error of 'Cannot Change a Built-In Header' at the second instance of cmProcessMain()(in bold). What am I doing wrong? Also, how the heck do I embed a paradox 9 script into a DBase table? Is it possible. I have been working on this for work all day, and my brain is fried. New insight would be great
;*********code for a script
method run(var eventInfo Event)
cmProcessMain()
endMethod
;******************************
method cmProcessMain()
var
strOrigSS,strNewSS string
tc tcursor
endvar
tbl = ":work:abraxport.dbf"
if not tc.open(tbl) then
errorshow("open tc error"
return
endif
tc.edit()
scan tc :
strOrigSS = tc."OrigSsFieldname"
if cmNoHyphen(strOrigSS,strNewSS)
then tc."NewSsFieldname" = strNewSS
else
msgInfo("Data odd : ",strOrigSS)
endif
endscan
tc.endedit()
tc.close()
endMethod
;*********************************
method cmNoHyphen(strOrig string, var strNew string) logical
;111-22-3333
; should be 9 + 2 = 11 long
if strOrig.size() <> 11 or
strOrig.substr(4,1)<> "-" or
strOrig.substr(7,1)<> "-"
then
return(false)
endif
stNew = strOrig.substr(1,3) + ; 111
strOrig.substr(5,2) + ; 22
strOrig.substr(8,4) ; 3333
return(true)
endMethod
I get an error of 'Cannot Change a Built-In Header' at the second instance of cmProcessMain()(in bold). What am I doing wrong? Also, how the heck do I embed a paradox 9 script into a DBase table? Is it possible. I have been working on this for work all day, and my brain is fried. New insight would be great