Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2003
    Location
    Texas
    Posts
    3

    Question Unanswered: 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 Attached Files
    Last edited by nawtykitty; 09-26-03 at 16:46.

  2. #2
    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()

  3. #3
    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 Attached Files

  4. #4
    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 17:56.

  5. #5
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •