Donate Now Goal amount for this month: 100 USD, Received: 0 USD (0%)
Donate to support this site and ThinBASIC project development

Results 1 to 8 of 8

Thread: Multiple BIFF File Creation

  1. #1
    Member
    Join Date
    Jan 2010
    Location
    Montreal, Canada
    Posts
    40
    Rep Power
    9

    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

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    47
    Posts
    7,622
    Blog Entries
    2
    Rep Power
    10

    Re: Multiple BIFF File Creation

    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

    [code=thinbasic]
    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
    [/code]
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  3. #3
    Member
    Join Date
    Jan 2010
    Location
    Montreal, Canada
    Posts
    40
    Rep Power
    9

    Re: Multiple BIFF File Creation

    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

  4. #4
    Super Moderator Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Leverkusen, Germany
    Age
    48
    Posts
    3,151
    Blog Entries
    2
    Rep Power
    324

    Re: Multiple BIFF File Creation

    Rick, can you please post the full path where you run this script? I have a feeling it is path related.

  5. #5
    Member
    Join Date
    Jan 2010
    Location
    Montreal, Canada
    Posts
    40
    Rep Power
    9

    Re: Multiple BIFF File Creation

    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

  6. #6
    Super Moderator Michael Hartlef's Avatar
    Join Date
    Sep 2006
    Location
    Leverkusen, Germany
    Age
    48
    Posts
    3,151
    Blog Entries
    2
    Rep Power
    324

    Re: Multiple BIFF File Creation

    Thanks Rick, so you have spaces inside the path. Try this version, I can't test it here myself atm.

    [code=thinbasic]
    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
    [/code]

  7. #7
    Member
    Join Date
    Jan 2010
    Location
    Montreal, Canada
    Posts
    40
    Rep Power
    9

    Re: Multiple BIFF File Creation

    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

  8. #8
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    47
    Posts
    7,622
    Blog Entries
    2
    Rep Power
    10

    Re: Multiple BIFF File Creation

    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
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •