View Full Version : Multiple BIFF File Creation
The following code snippet appears to comply with the BIFF rules regarding working with only one file at a time. However, for FileCount = 3, it creates only one proper file with all data written (for i = 1). Two others are created with the proper names and in the proper place, but they are empty, 4-byte files containing only the last 4 bytes of a proper file (0A-00-00-00). Any ideas what I am doing wrong?
FOR i = 1 TO FileCount
'---Create the output file
BIFF_CreateFile (APP_ScriptPath & OutFileName & "-" & i & ".xls")
'---Create the header string
HeaderStr = "File " & OutFileName & "-" & i & ".xls"
HeaderStr += " created on " & MyDateStr
HeaderStr += " at" & TIME$
'---Write out the data
BIFF_WriteText (HeaderStr, 1, 1)
BIFF_WriteText (StrBuffer(i), 3, 1)
BIFF_CloseFile
NEXT
ErosOlmi
14-01-2010, 00:15
Because I cannot execute your example (some code is missing, definition of variables ...) I created a new example hoping it is what you was trying to do.
Here is seems all is working as expected: four files created each with its different content.
But let me know
Uses "Biff"
Uses "Console"
Dim Counter As Number
Dim OutFile As String
Dim HeaderStr As String
For Counter = 1 To 4
OutFile = APP_SourcePath & "Test" & "-" & Counter & ".xls"
PrintL "Creating file " & OutFile
'---Create the output file
BIFF_CreateFile (OutFile)
'---Create the header string
HeaderStr = "File " & OutFile
HeaderStr += " created on " & Date$
HeaderStr += " at " & Time$
'---Write out the data
BIFF_WriteText (HeaderStr, 1, 1)
BIFF_CloseFile
Sleep 1000
Next
Eros;
Your snippet works properly, but if I paste it into my app (with suitable name changes), it still fails. I have no idea, but it must be something I am doing prior to this.
In any case, I am abandoning this idea. The data I am putting out is all sequential, so formatting and saving it as a CSV is actually easier since I do not have to keep track of row and column positions. Since CSV is also a native Excel format, there is no big issue as far as what I deliver is concerned.
Thanks for the help.
Rick Gasoi
Michael Hartlef
16-01-2010, 19:00
Rick, can you please post the full path where you run this script? I have a feeling it is path related.
Michael;
The script is in the same path as my input and output files - C:\Documents and Settings\Rick Gasoi\My Documents\Consulting\Girolami\Projects\EDO
Girolami is my customer and EDO is their customer.
Rick
Michael Hartlef
18-01-2010, 18:13
Thanks Rick, so you have spaces inside the path. Try this version, I can't test it here myself atm.
Uses "Biff"
Uses "Console"
Dim Counter As Number
Dim OutFile As String
Dim HeaderStr As String
For Counter = 1 To 4
' OutFile = APP_SourcePath & "Test" & "-" & Counter & ".xls"
OutFile = CHR$(34) & APP_SourcePath & "Test" & "-" & Counter & ".xls" & CHR$(34)
PrintL "Creating file " & OutFile
'---Create the output file
BIFF_CreateFile (OutFile)
'---Create the header string
HeaderStr = "File " & OutFile
HeaderStr += " created on " & Date$
HeaderStr += " at " & Time$
'---Write out the data
BIFF_WriteText (HeaderStr, 1, 1)
BIFF_CloseFile
Sleep 1000
Next
Michael;
As I noted, I am no longer using the BIFF module, having opted instead to output my data in .CSV format. Thus, I have not pursued this issue. However, I would note that Eros's snippet from Jan 13 ran properly in the same directory as mine, so this is not the problem. It may be a result of my also using the "FILE" module and, prior to calling any BIFF functions, I have opened and closed a file using this module (to read the input data).
Rick
ErosOlmi
22-01-2010, 16:56
Hi Rick,
just in case you would like to try to solve the problem you mentioned in first post, I need a working example (even minimal) that can replicate the problem so I can test and hopefully solve it if it is a bug.
Ciao
Eros