Results 1 to 12 of 12
  1. #1
    Join Date
    Nov 2004
    Posts
    7

    Unanswered: Need help with Locate and Replace

    I have a table in Paradox 9 that I need to be able to do a locate and replace on one of the 2 fields. Here is the situation. I have a database of Schools that will have 2 fields, a ClosedCondition field and a Institution field. There is no problem with the Institution field, but on the ClosedCondition field I need some help. This field will contain anything from the word OPEN to the words OPEN SNOW ROUTE to OPEN PAVED ROUTES along with CLOSED and many other variations. I need to be able to "blank" out the ClosedCondition field if it contains the word OPEN, but, do to typo's, it may also have a space before the word OPEN or a ' after the word OPEN'. And I need the OPEN SNOW ROUTE or OPEN WHATEVER left alone. I just need to be able to blank out the field if it is OPEN. I am new to this database and would love it if it could be something simple. Thanks for any and all help.

    Apaddle

  2. #2
    Join Date
    Oct 2003
    Posts
    706
    Hmmm... extemporaneous coding here...
    Code:
    var fv String endvar
    
    isClosed = False
    if not ClosedCondition.IsBlank() then
      fv = UpperCase(ClosedCondition.Value())
      if fv.StrPos("CLOSED") > 0 then   // not sure of func name...
        isClosed = True
      endif
    endif
    Something vaguely sorta like that?

    You might be able to use advMatch. Also, the scan for statement, in the for clause, allows you to quickly scan for records that might match what you're looking for.

    There are several ways to do it. Hope this helps.
    ChimneySweep(R): fast, automatic
    table repair at a click of the
    mouse! http://www.sundialservices.com

  3. #3
    Join Date
    Nov 2004
    Posts
    7

    Question That is what I am looking for but....

    I am VERY new to paradox, how would I go about using this code? A Script? I'll be honest, HELP!

    Thanks

    Apaddle

  4. #4
    Join Date
    Sep 2003
    Location
    Dallas
    Posts
    182

    A different view.

    Since a route is either open or closed, you should add a logical Fieldtatus which had only display values Open = True or Closed = False. Then you could set up your script so that when ever the status is changed to open the Closed condition field would go to Blank. When it is changed to closed it would could have a dialog box pop up to fill in the condition. This is not difficult an would actually speed up the process considerably and allow you to better control the typo's

  5. #5
    Join Date
    Nov 2004
    Posts
    7

    Question another good answer...but

    Thanks, but the problem is I am importing text data from a website and after stripping off the html code I am left with a delimited file and import that into a secondary Paradox table. This is where I need to remove the OPEN, but only the OPEN. As I said earlier, there are occassional typos and that is what is getting me in trouble, not my typo's, the ones that are being imported. I need to be able to remove OPEN, OPEN', or (space)OPEN but not remove OPEN SNOW ROUTES ONLY. Would probably be easy if I knew how to program in objectPal?

    Apaddle

  6. #6
    Join Date
    Sep 2003
    Location
    Dallas
    Posts
    182

    Here's the meat of the solution

    var opentc: tcursor
    x,y:string
    tcursor.open("your file name here")
    tcursor.edit()
    tcursor.scan for tcursor.yourfield.match("..OPEN..",x,y)
    tcursor .yourfieldname = blank
    endscan

    the tcursor is your trip through the table

    The scan steps through the entire table one record at a time but stops where "OPEN" is found anywhere in your field. It then assigns the value blank to the field and goes to the next record.

    The syntax may not be absolutely accurate as I did it in my head but the steps and commands are accurate.

  7. #7
    Join Date
    Sep 2003
    Location
    Dallas
    Posts
    182
    var opentc: tcursor
    x,y:string
    tcursor.open("your file name here")
    tcursor.edit()
    tcursor.scan for tcursor.yourfield.match("..OPEN..",x,y)
    If not y.match(..Snow..Routes..) then tcursor .yourfieldname = ""
    endscan

    {I added a line to check for snow routes before blanking the field.

  8. #8
    Join Date
    Nov 2004
    Posts
    7

    Perfect

    That is exactly what I am looking for, but now the dumb question, where do I put this code and how do I get it to run?

    Apaddle

  9. #9
    Join Date
    Sep 2003
    Location
    Dallas
    Posts
    182

    Open a new script

    Add the code and then play it from the project manager.

    by the way I left out qoutes in this line

    If not y.match("..Snow..Routes..") then tcursor .yourfieldname = ""
    Last edited by Maroonotmoron; 11-11-04 at 15:52.

  10. #10
    Join Date
    Nov 2004
    Posts
    7

    OK, now I really feel stupid?

    When I opened a new script I got:

    method run (var eventInfo Event)

    end method

    so I inserted the info you gave me after the method run and before end method? Checked syntax and got an, error: type expected, after the opentc: command? Any help would be SO appreciated.

    Apaddle

  11. #11
    Join Date
    Nov 2004
    Posts
    7

    Talking OK, I figured this one out?

    Thanks for your help, I got it figured out. Thanks again.

    Apaddle

  12. #12
    Join Date
    Sep 2003
    Location
    Dallas
    Posts
    182

    Red face Sorry I didn't respond sooner!

    so you figured out that I hadn't changed the opentc for the generic tcursor. That's what happens when you write stuff on the fly and don't go back to check if the details. Good for you!

Posting Permissions

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