print#,write" not working

General FreeBASIC programming questions.
jevans4949
Posts: 1156
Joined: May 08, 2006 21:58
Location: Crewe, England

print#,write" not working

Postby jevans4949 » Apr 23, 2020 10:11

Code: Select all

#Include Once "crt/stdio.bi"
#Include "jevans4949/csvread.bi"
#Include "jevans4949/getfname.bi"


'***********************************************************************
' Test Driver
'***********************************************************************
Dim y As csvfile Ptr
Dim R As Integer
Dim q As String
Dim As Integer i,j,k
Dim ff As Long
Print"Started"
y=New csvfile
y->buffsize=8192
ff=FreeFile
Open "p:csvreader.log" For Output As #ff

Do
Select Case q
   Case "N","n" 'next
      R = csvread(*y)
      Print "rc:";r
      If r = 5 Then
         Exit do
      EndIf
      write #ff,"Name:", y->fields(8)
   Case "w","W" 'next loop
      While y->nrows<500
      R = csvread(*y)
      If r=2 Then
        write #ff,"Name:",y->fields(8)
      Else
           Print "rc:";r
           
         Exit Do
        EndIf
      Wend
   
   Case "Q","q" 'quit
      Exit Do
   Case "P", "p"
      Print "File Handle: ";Hex(y->fptr,8)
      Print "File Name: ";*y->fname
      print  "Is open:";y->isopen
      Print "At EOF:";y->ateof
      Print "UTF:";y->utf
      Print "Buff pos";y->bb
      Print "Buff end";y->be
      Print "Rows Retrieved:";y->nrows
      Print "Columns:";y->fi
   Case "B","b"
      j= y->bb-10
      If j<1 Then j=1
         k=j+20
      If k>UBound(y->buff) Then k = UBound(y->buff)
      For i = j To k
         If y->buff(i)>32 Andalso y->buff(i)<126 Then
            Print Chr(y->buff(i));
         else
           Print "[";Hex(y->buff(i),2);"]";
         EndIf
      Next
   Case "h","H"
      For i=i To UBound(y->headers)
         Print y->headers(i)                                          
      Next
   Case "d","D"
      For i =1 To ubound(y->fields)
         Print y->fields(i)
      Next      
End Select
Close #ff
Input q
Loop
sleep



Wrote this program to test a Library, CSVREAD, which I have written and it works, but the WRITE# statements to produce a log file don't seem to work. I used WRITE# as PRINT# didn't work eiher. WRITE without # goes to console with expected results. The file is just empty. Tried writing to different drive, same non-result. Any clues?
Using compiler version 1.07.1 64bit.
badidea
Posts: 2148
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: print#,write" not working

Postby badidea » Apr 23, 2020 14:34

"p:csvreader.log" is that legal? "p:\csvreader.log"?
jevans4949
Posts: 1156
Joined: May 08, 2006 21:58
Location: Crewe, England

Re: print#,write" not working

Postby jevans4949 » Apr 23, 2020 17:01

badidea wrote:"p:csvreader.log" is that legal? "p:\csvreader.log"?

it created the file on my remote drive. Trouble is, nothing got written to it.
fxm
Posts: 9934
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: print#,write" not working

Postby fxm » Apr 23, 2020 18:19

Code: Select all

.....
.....
End Select
'Close #ff
Input q
Loop
Close #ff
sleep

Return to “General”

Who is online

Users browsing this forum: No registered users and 7 guests