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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

importing a data to the data window

Status
Not open for further replies.

paul102384

Programmer
Oct 5, 2007
30
hi to all pb programmers,

i want to import a text file(tab delimited) to the datawindow
whereas in a text file, for every line, the first character should be letter D or H,
and then, D should be imported to 1st datawindow or dw_1 while H will go to another datawindow which is dw_2...

e.g.
H 1001 0 4894.04000
D 1002 0 4895.04000
H 1003 0 4896.04000

my codes looks like this:

docpath = w_glimport.sle_1.Text
i_open = FileOpen(docpath, LineMode!)//
i_read = FileRead(i_open, s_input)//
s_im = mid(s_input,1,1)//
IF s_im = 'H' THEN//
import = dw_1.ImportFile(Text!,docpath)//
END IF

- the problem is the import variable returns -2 which means empty file and no records or data can be imported..

can someone give me the codes to fix this problem..

tnx...
 
Hi,

I think thereis a mistake in your logic.

1. the file is already opened when you try to execute dw_1.importFile(...)
2. your code would import into dw_1 all rows

try this:

Code:
docpath = w_glimport.sle_1.Text
dw_1.import(text!, docpath)
dw_1.SetFilter( "#1 = 'D')
dw_1.Filter()

dw_2.import(text!, docpath)
dw_2.SetFilter( "#1 = 'H')
dw_2.Filter()

OR id you want to have no rows in the filtered buffer

Code:
docpath = w_glimport.sle_1.Text
dw_1.import(text!, docpath)
dw_1.SetFilter( "#1 <> 'D')
dw_1.Filter()
ll_rows = dw_1.rowcount()
FOR ll_row = ll_roes to 1 step -1
   dw_1.DeleteRow( ll_row)
NEXT
dw_1.SetFilter("")
dw_1.Filter()

dw_2.import(text!, docpath)
dw_2.SetFilter( "#1 <> 'H')
dw_2.Filter()
ll_rows = dw_2.rowcount()
FOR ll_row = ll_roes to 1 step -1
   dw_2.DeleteRow( ll_row)
NEXT
dw_2.SetFilter("")
dw_2.Filter()


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top