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 > Need help with Locate and Replace

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-05-04, 09:13
apaddle apaddle is offline
Registered User
 
Join Date: Nov 2004
Posts: 7
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
Reply With Quote
  #2 (permalink)  
Old 11-06-04, 10:55
sundialsvcs sundialsvcs is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 11-08-04, 07:35
apaddle apaddle is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 11-08-04, 14:43
Maroonotmoron Maroonotmoron is offline
Registered User
 
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
Reply With Quote
  #5 (permalink)  
Old 11-08-04, 15:28
apaddle apaddle is offline
Registered User
 
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
Reply With Quote
  #6 (permalink)  
Old 11-09-04, 11:54
Maroonotmoron Maroonotmoron is offline
Registered User
 
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.
Reply With Quote
  #7 (permalink)  
Old 11-09-04, 12:00
Maroonotmoron Maroonotmoron is offline
Registered User
 
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.
Reply With Quote
  #8 (permalink)  
Old 11-11-04, 07:21
apaddle apaddle is offline
Registered User
 
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
Reply With Quote
  #9 (permalink)  
Old 11-11-04, 14:50
Maroonotmoron Maroonotmoron is offline
Registered User
 
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 14:52.
Reply With Quote
  #10 (permalink)  
Old 11-12-04, 08:04
apaddle apaddle is offline
Registered User
 
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
Reply With Quote
  #11 (permalink)  
Old 11-12-04, 10:38
apaddle apaddle is offline
Registered User
 
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
Reply With Quote
  #12 (permalink)  
Old 11-16-04, 17:03
Maroonotmoron Maroonotmoron is offline
Registered User
 
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!
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