Hi Guys,
I'm going to post a simple program I created that uses the Enhancement Pak data functions to convert an XL .csv file into a plain flat sequential file. Its been in use since last May so I know it works. I can't tell you what you're doing wrong. All I can say is I had similar difficulties at first. It took forever to get the first version of this to run. I don't think I ever found out why it didn't at first. But I will mention this: Excel has 3 different CSV export formats. Maybe you're not using the right one. I'm pretty sure I use the one that says CSV (Comma delimited) which is redundant since that's what CSV means.
Here's the sample program:
Rem Project: CSV_Auto
Rem Created: 5/17/2007 9:41:04 AM
Rem Modified: 11/12/2007
Rem ***** Main Source File *****
a$ = cl$() ` file name passed by commandline
If not file exist(a$)
Crash$=a$ + "?? File Not Found."
Crash(Crash$)
EndIf
path$ = extract filepath$(a$)
Set Dir path$
sched$ = a$ : outfil$ = left$(sched$,len(sched$)-4)+".dbx"
If File exist(outfil$) then delete file outfil$
Seperator$=","
Open Data File sched$, Seperator$, 1
Open to Write 1, outfil$
Write String 1, "black.jpg"
Write String 1, "00:00:00"
Write String 1, "07:00:00"
Write String 1, "01/01/01"
Write String 1, "99/99/99"
Write String 1, "30"
Write String 1, " "
Write String 1, "black.jpg"
Write String 1, "18:00:00"
Write String 1, "23:59:00"
Write String 1, "01/01/01"
Write String 1, "99/99/99"
Write String 1, "30"
Write String 1, " "
Rows = GET DATA FILE ROW COUNT(1) : Columns = GET DATA FILE COLUMN COUNT(1)
For x = 1 to Rows
code$="" : dat$ = GET DATA FILE CELL(1,1,x) : t = asc(left$(dat$,1))
If (t>47 and t<58) or instr(dat$,"always",1,0)>0
media$ = GET DATA FILE CELL(1,6,x)
Sec$ = GET DATA FILE CELL(1,4,x)
Dur$ = str$(Val(Sec$))
sd$ = GET DATA FILE CELL(1,1,x)
If instr(sd$,"always",1,0)
sd$ = "01/01/01"
ed$ = "99/99/99"
code$ = code$ + "ad"
Else
sd$ = Fixdate(sd$)
ed$ = Fixdate(GET DATA FILE CELL(1,2,x))
EndIf
st$ = GET DATA FILE CELL(1,3,x)
If instr(st$,"al",1,0)
st$ = "00:00:00"
et$ = "23:55:00"
code$ = code$+"at"
Else
st$ = st$
et$ = "18:00:00"
EndIf
Write string 1, media$
Write string 1, st$
Write string 1, et$
Write string 1, sd$
Write string 1, ed$
Write string 1, Dur$
Write String 1, Code$
EndIF
Skip2:
Next x
CLOSE DATA FILE 1
Close File 1
End
Function Fixdate(date$ as string)
k1 = instr(date$,"/",1) : k2 = instr(date$,"/",k1+1)
m$ = left$(date$,k1-1): d$ = mid$(date$,k1+1)
if k1+2<>k2 then d$ = d$+ mid$(date$,k1+2)
y$ = right$(date$,2)
If len(m$)<2 then m$ = "0" + m$
If Len(d$)<2 then d$ = "0" + d$
date$ = m$+"/"+d$+"/"+y$
EndFunction date$
Function Crash(crash$)
a = Message Box(crash$,"Warning: Program will exit! ",4,0)
End
EndFunction
Another useful tidbit... I had to regularly convert data from an Excel workbook (multipage) and the .CSV format makes no allowance for multipage. I found that Excel can export an entire workbook to an XML format that is multipage. And although the Enhancement Pak's XML functions proved absolutely useless, I was able to load the file into my app as a string text file and parse it myself searching for tages like <page> </page> using instr$ functions.
What killed me most about the "enhancements pak" was the fact that the data functions were completely missing from the help file.
Good Luck Guys!
The answer to Life, the Universe, and Everything? "Tea for Two". Deep Thought was Dyslexic.