on 08-26-2015 4:14 PM
I am trying to parse a tab-delimited file but it fails everytime. The file is generated using the code
ls_ColName = TRIM(adw_object.Describe("DataWindow.Objects"))
Method 1: I created a external datawindow with one column in it. Then imported it to datawindow
dw_1.ImportString(ls_ColName)
Even though the above statement returns 1 but what it fails to create a stack of fields available in ls_ColName.
Method 2: Using POS and MID
String ls_ColName
ll_cnt = 0
long ll_pos, ll_mov
String ls_space, ls_objectType
String ls_mid
ls_space = ' ' //copied the space between fields from attached file
ll_mov = 1
ls_ColName = TRIM(adw_object.Describe("DataWindow.Objects"))
ll_len = Len(ls_ColName)
FOR ll_cnt = 1 TO ll_len
ll_pos = POS(ls_colName, ls_space, ll_cnt)
ls_mid = MID(ls_colName, ll_cnt, ll_pos - 1)
ls_mod = RIGHTTRIM(LEFTTRIM(ls_mid)) + ".Type"
ls_objectType = adw_object.describe(ls_mod)
ll_mov = ll_pos
ll_cnt = ll_pos
NEXT
The problem in method 2 is after finding the first field and its type, its starts concatenating the rest which fails to give the type.
The tab separated file is attached for reference.
Hi Ashish,
I would do what you are doing, but I would create an external datawindow with a large number of columns all of type string length 32766, then simply import the tab delimited text file.
Lars
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you guys.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ashish;
This is how my STD Foundation Class library does this ...
ls_objects = THIS.Describe("DataWindow.Objects")
ns_ds_master lo_ds
lo_ds = CREATE ns_ds_master
lo_ds.DataObject = 'dw_tabbed_name'
DO While TRUE
li_pos = POS (ls_objects, "~t")
IF li_pos > 0 THEN
ls_objects = Replace (ls_objects, li_pos, 1, '~r')
else
EXIT
END IF
LOOP
lo_ds.ImportString (ls_objects)
I have attached the DWO source (v12.1 of PB) FYR.
HTH
Regards ... Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.