Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want to substitute a blank field ditto?

Status
Not open for further replies.

Pharmer

Technical User
Aug 15, 2002
13
US
I am importing an Excel spreadsheet (from ASCII) where every "record" incorporates 5 lines. This results in a table where there is a 1 lines with a desciption including an item number followed by 5 line where that field is empty. Where table is open, I "shift-control-z" (find and replace)Pardadox finds the blank fields, but won't take control-D keystroke. I could do this manually, but the table has 7000 records..Is there a way to do this with OPAL script?(using Paradox-7)
 
Pharmer,

I have worked blind here and for example purposes assumed that you end up with a table (let's call it test) which has columns named A, B.....

Table Test
Column A B

Value_1 xcxcx
fdfdf
fgfgh
dsfds
sdfsdf
Value_2 vvvvv
dfdfs
ghfghg
dsdsd
hjghj

and so on.

In column A you want the blank fields to be the duplicates of the preceding field which holds a value so in my example Column A rows 2-5 would be populated with Value_1 and rows 6 - 10 would be populated with Value_2 and so on through the 7000 plus rows. (Of course if I have misunderstood your requirement then all of the following is useless)

An ObjectPal way of dealing with this is set out below
;======================================================
var
TC TCursor
Str String
EndVar

;Below please substitute "test" with your own table name
;and path as necessary
;also substitute "A" with your own field name

TC.open("test"); open a TCursor to read your table
TC.edit();set the TCursor to edit the table

;==========================================================
;use the TCursor to scan the table. Everytime it gets to
;a value in column A this is stored in a variable
;called Str. The next blank fields is given the value
;stored in Str. Str changes the next time it encounters a
;a non blank field.
;==========================================================
Scan TC:
if TC."A".isblank()=False then
Str=TC."A"
else
TC."A"=Str
endif
EndScan

TC.endedit()
TC.close()
;==========================================================

I have commented the code quite heavily so that you can see what it is doing. I am confident that it will work on version 7. It just needs to be pasted into a button on a form in between Method and EndMethod.

I hope that this works. If you have any problems please post again.

Regards

Bystander

 
Worked very well ("instantly")-thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top