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 > Delete Specific Array[] Assignments

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-05-04, 12:34
Rick Schreiber Rick Schreiber is offline
Registered User
 
Join Date: Mar 2004
Location: California
Posts: 400
Delete Specific Array[] Assignments

I have this in Paradox Ver.7 table. (Over 5,000 records)

NEWPORT COAST STATE CA
OCEANSIDE STATE CA
CORONA DEL MAR STATE CA
LA JOLLA STA

I need to delete everything from the word, or partial word "STATE" and all that is to the right of it.

I can parse this out in an Array[] but how can I delete specific array assignments?

Thanks in Advance.

Rick (RickinNpt@cs.com
Reply With Quote
  #2 (permalink)  
Old 03-05-04, 14:25
lmckelvy lmckelvy is offline
Registered User
 
Join Date: Oct 2003
Posts: 107
I would probably use breakapart() to get my array, then test each element in a loop. Count the iterations and only put back the number of elements up to and including "sta" or "state" in an assignment back to the field value.
Reply With Quote
  #3 (permalink)  
Old 03-05-04, 14:42
Rick Schreiber Rick Schreiber is offline
Registered User
 
Join Date: Mar 2004
Location: California
Posts: 400
Quote:
Originally posted by lmckelvy
I would probably use breakapart() to get my array, then test each element in a loop. Count the iterations and only put back the number of elements up to and including "sta" or "state" in an assignment back to the field value.
How would I test each element in Breakapart() AND in Array[] ?

Thanks . . . Rick
Reply With Quote
  #4 (permalink)  
Old 03-05-04, 18:06
lmckelvy lmckelvy is offline
Registered User
 
Join Date: Oct 2003
Posts: 107
This is an example of how to apply it. Just stick it in a script to demo it. You would want to modify this to place it inside a scan loop in order to assign the Addy variable..

Code:
var 
  myAr Array[] String ; Must be resizable
  Addy String
  numEl longint
  cntr  longint
  redo  longint	
endvar 

redo = 1

Addy = "NEWPORT COAST STATE CA"

Addy.breakApart(myAr)

numEl = myAr.size()

view(myAr)
for cntr from 1 to numEl

	if myAr[cntr].subStr(1,3) = "STA"
		then 	Addy = ""
				while redo <= cntr
					Addy = Addy+myAr[redo]
					if redo <> cntr then Addy = Addy+" " endif
					redo = redo+1
				endwhile
				quitloop
	endif					
				




endfor

Addy.view()
I'll be out of town for a few days, but will try to answer any questions when I get back.
Reply With Quote
  #5 (permalink)  
Old 03-05-04, 20:14
Rick Schreiber Rick Schreiber is offline
Registered User
 
Join Date: Mar 2004
Location: California
Posts: 400
Thanks . . .

I'll try this out tonight and let you know what I come up with.

Thanks again . . . Rick
Reply With Quote
  #6 (permalink)  
Old 03-05-04, 21:36
Rick Schreiber Rick Schreiber is offline
Registered User
 
Join Date: Mar 2004
Location: California
Posts: 400
Here is script with comments!

method run(var eventInfo Event)
Var
tc TCursor
myar Array[] String ; Must be resizable
Addy String
Cntr longint
Numel longint
Redo longint
SDRoster table
endVar
;-----------------------------------------------------------------
addAlias("MYDIR","Standard","D:\\Pdoxwin7\\SanDieg o\\SDRoster.db")
;-----------------------------------------------------------------
if Not tc.open("D:\\Pdoxwin7\\SanDiego\\SDRoster.db") then ;table name
errorShow()
return
endif
tc.edit()
scan tc:
redo = 1
Addy=tc."City"
Addy.breakapart(myar)
numel = myar.size()

for cntr from 1 to numel

if myar[cntr].substr(1,3) = "STA.." ;keeps returning to the redo = 1 line???
then addy = "" {Also subsrt (1,3) can be anywhere from
1 to 6}
While redo <=cntr
addy = addy+myar[redo]
if redo<>cntr then addy = addy+""
endIf

redo=redo+1
Message("Processing Record No. ", tc.recno())
If tc.eot() then
Message("Reached the end of the table Rick...")
endIf

endWhile
quitloop
endIf
endFor
endScan
endMethod
;==============================(eND)============== =================
Reply With Quote
  #7 (permalink)  
Old 03-15-04, 12:39
lmckelvy lmckelvy is offline
Registered User
 
Join Date: Oct 2003
Posts: 107
Hey Rick,

I got back and looked at your post. I have modified your script as follows and sent it to you in an email. I'm posting here in case anyone else is interested in the solution.

The problems were:

> if myar[cntr].substr(1,3) = "STA.." ;keeps returning to the redo = 1
> line???

This was caused by your addition of the ".."

The original line simply looked at the first three characters of the current array element. If they were "STA" then it was assumed that the word was STA or STATE.


> {Also subsrt (1,3) can be anywhere from 1 to 6}

Not sure what you mean by this, maybe I answered it above.


> if redo<>cntr then addy = addy+"" endIf

There has to be a space between the quotes.



> If tc.eot() then Message("Reached the end of the table Rick...") endIf

I remarked this out. If needed, you can just stick:

Message("Reached the end of the table Rick...")

after the endScan. The scan stops automatically at the end of the table when the last record is reached and any code within the scan loop has been executed.


This will modify every record so that everything to the right of STA or STATE will be gone.

Cheers,

Mac
Reply With Quote
  #8 (permalink)  
Old 03-16-04, 06:22
fepsy fepsy is offline
Registered User
 
Join Date: Jan 2004
Location: amsterdam
Posts: 31
I don't understand why you have to program this when there is an easy solution to it. Export to delimited ascii into a wordprocessor, with a macro remove from "sta" to the end of line and import back into paradox. This will cost you only 1 minute.
Reply With Quote
  #9 (permalink)  
Old 03-16-04, 09:13
lmckelvy lmckelvy is offline
Registered User
 
Join Date: Oct 2003
Posts: 107
> I don't understand why you have to program this


I don't know if it is to be a one-shot deal or not. Certainly it would have been simpler to do it the way you describe - provided one was well versed in creating word processing macros that picked words out of the middle of a line. However, if the process needs to be automated then the less software involved the better, in my opinion.

Besides, it was good practice
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