If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Corel Paradox > Remove Hyphens with a Paradox 9 Script

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-26-03, 15:37
nawtykitty nawtykitty is offline
Registered User
 
Join Date: Sep 2003
Location: Texas
Posts: 3
Question Remove Hyphens with a Paradox 9 Script

I am trying to create a process script in Paradox 9 that will remove hyphens from a field. The field name is P_SSN and the data is social security numbers with hyphens. Before I can export the data to another application, the hyphens must go. Here is my script so far:


proc NoHyphen (strP_SSN string) string var strTemp, strFront,strBack
string strTemp=strP_SSN while strTemp.match("..-..",strFront,strBack)
strTemp=strFront+strBack endwhile return strTemp endproc

When I check the syntax, I get an "Error: Identifier Expected" on the first 'strTemp'. What am I doing wrong? Am I even close or waaaaaayyyyyyy off? And yes...I am a newb at the ol' Paradox. Please be gentle Seriously, any and all help would be greatly appreciated. Thanx.

P.S.
I have attached a text document with my string statement for editing purposes. Once again, thank you.
Attached Files
File Type: txt string.txt (221 Bytes, 91 views)

Last edited by nawtykitty; 09-26-03 at 15:46.
Reply With Quote
  #2 (permalink)  
Old 10-01-03, 03:03
Maroonotmoron Maroonotmoron is offline
Registered User
 
Join Date: Sep 2003
Location: Dallas
Posts: 182
proc NoHyphen (strP_SSN string)
var strTemp,strFront,strBack string endvar
strTemp=strP_SSN.value
while strTemp.match("..-..",strFront,strBack)
strTemp=strFront+strBack
endwhile
return strTemp
endproc

Your variable declaration was not formed properly and the insertion of the string keyword was incorrect as well.

You can make the procedure (I believe, I did not test it) as edited above however I would use a tcursor and use a scan instead, see below. It would take care of the entire table in one quick pass. The "yourtable.db" is the name of the paradox table and it must be double quoted iside the parentheses.

proc nohyphen()
var nohyphen tcursor, x,y string endvar
nohyphen.open('"yourtable.db"')
nohyphen.edit()
scan nohyphen for nohyphen.strp_ssn.match("..-..",x,y):
tcfix.strp_ssn = x + y
endscan
tcfix.endedit()
Reply With Quote
  #3 (permalink)  
Old 10-02-03, 13:08
nawtykitty nawtykitty is offline
Registered User
 
Join Date: Sep 2003
Location: Texas
Posts: 3
Question

I have taken your script and reworked it so that it would match my table. However I get an Unknown Identifier Error on tcfix.strp_ssn=x+y. Does p_ssn need to be defined elsewhere or does Paradox autmatically know that it is a field within the table. If not, could that be the root cause of the error. Here is the revised script so far:

proc nohyphen()

var nohyphen tcursor tc, x,y string
endvar
nohyphen.open("abratest.db")
nohyphen.edit()

scan nohyphen for nohyphen.strp_ssn.match("..-..",x,y):
tcfix.strp_ssn = x + y

endscan
tcfix.endedit(
endproc

I do not have anything else under the run, var, const, etc etc in this script defining p_ssn. If it needs to be defined where and how would that be accomplished? I have attached the script to a text file in case anyone wants to look at it. I really do appreciate all the help so far. Cheers
Attached Files
File Type: txt script.txt (236 Bytes, 107 views)
Reply With Quote
  #4 (permalink)  
Old 10-02-03, 16:51
Maroonotmoron Maroonotmoron is offline
Registered User
 
Join Date: Sep 2003
Location: Dallas
Posts: 182
I'm sorry replace tcfix with nohyphen tcfix was a name leftover from my script which i pulled over and modified for your problem. Also if strp_ssn is not the name of your field (meaning it is really p_ssn) then strip out the str where ever it exists as well. Paradox knows the field name and will fail if it doesn't match.

Also looks like you might be missing a closing parenthesis at tcfix.endedit (. (soon to be nohypen.endedit().)

Last edited by Maroonotmoron; 10-02-03 at 16:56.
Reply With Quote
  #5 (permalink)  
Old 10-03-03, 17:29
nawtykitty nawtykitty is offline
Registered User
 
Join Date: Sep 2003
Location: Texas
Posts: 3
Lightbulb Final Result of Script

With a lot of help (if not all) from Maroonotmoron here is the final resulting script that was developed (The name of my database file was "Abraxport.DBF" and the field that I needed to have the hyphens removed was P_SSN) :

Under the Proc Window:

proc nohyphen()

var nohyphen tcursor tc, x,y string
endvar
nohyphen.open("abraxport.DBF")
nohyphen.edit()

scan nohyphen for nohyphen.p_ssn.match("..-..",x,y):
nohyphen.p_ssn = x + y

endscan
nohyphen.endedit()

endproc

Under the Run Window:

method run(var eventInfo Event)

nohyphen()

endMethod


I have to run the script twice, but it gets the job done nicely. Once again many thanx go to Maroonotmoron for his tremendous help!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On