migrate to SQL
Hi Grant,
Here’s a generic method for passing a list to a tab-delimited file. It does not deal properly with binary/picture/list fields in the list columns, it assumes that it’s all character and numeric data. It starts the file with a line of the list’s column names, but you could add a parameter and some code to make that conditional behavior. It also prompts for the destination unconditionally, but could be easily modified to accept a full path and skip the file dialog.
Kelly
##### Method ‘listToTabbedFile’ #####
No. Parameter Type Subtype Init.Val/Calc Description
1 pList Field reference
2 pSuggestedName Character 100000000 ‘ListOutput.txt’
No. Local Variable Type Subtype Init.Val/Calc Description
1 col Long integer
2 colCount Long integer
3 err Long integer
4 fop Object .FileOps.FileOps
5 lineCount Long integer
6 lineText Character 100000000
7 outPath Character 100000000
No. Method text
1 ;
2 Calculate outPath as pSuggestedName
3 Do FileOps.$putfilename(outPath,’Save list as:’) Returns err
4 If (err=1)&(outPath<>”)
5 Calculate lineCount as pList.$linecount
6 Calculate colCount as pList.$cols.$count()
7 Calculate lineText as ”
8 For col from 1 to colCount step 1
9 Calculate lineText as con(lineText,pick(lineText=”,chr(9),”),pList.$cols.[col].$name)
10 End For
11 Do FileOps.$doesfileexist(outPath) Returns #F
12 If flag true
13 Do FileOps.$deletefile(outPath) Returns err
14 End If
15 Do fop.$createfile(outPath) Returns err
16 Do fop.$writefile(con(lineText,chr(13))) Returns err
17 For pList.$line from 1 to lineCount step 1
18 Calculate lineText as ”
19 For col from 1 to colCount step 1
20 Calculate lineText as con(lineText,pick(lineText=”,chr(9),”),pList.C[col])
21 End For
22 Do fop.$writefile(con(lineText,chr(13))) Returns err
23 End For
24 Do fop.$closefile() Returns err
25 End If
No method errors found
_____________________________________________________________
Manage your list subscriptions at lists.omnis-dev.com