Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C file functions in QB64 ???
#5
Hi DSMan195276
you were right, byval fixed it Smile
I should have seen it, it was there right in front of me Angry
when you use a DLL you are not bothered by type correctness, just as long as the data will fit in the type it works
that's why in my second attempt I used Declare Dynamic Library "msvcrt"
thanks for opening my eyes Smile
Code: (Select All)
Declare Dynamic Library "msvcrt"
    Function fopen%& (file_name As String, mode As String)
    Function fclose& (ByVal file_ptr As _Offset)
    Function fprintf& (ByVal file_ptr As _Offset, frmt As String, st As String)
    Function fread~&& (buff As String, Byval size As _Unsigned _Integer64, Byval count As _Unsigned _Integer64, Byval file_ptr As _Offset)
End Declare

Dim As _Offset fp
Dim As String fln, md, frmt, text
Dim As Long status

fln = "fopen1-test.txt" + Chr$(0)
md = "w" + Chr$(0)
frmt = "%s" + Chr$(13) + Chr$(10) + Chr$(0) '\n didn't work but + Chr$(13) + Chr$(10) does work
text = "hello world" + Chr$(0)

fp = fopen(fln, md)
status = fprintf(fp, frmt, text)
status = fclose(fp)

md = "r" + Chr$(0)
text = Space$(64) + Chr$(0)
fp = fopen(fln, md)
status = fread(text, 1, 64, fp)
Print text

it displays hello world
Reply


Messages In This Thread
C file functions in QB64 ??? - by Jack - 04-26-2023, 11:00 AM
RE: C file functions in QB64 ??? - by Jack - 04-26-2023, 11:34 AM
RE: C file functions in QB64 ??? - by DSMan195276 - 04-26-2023, 01:16 PM
RE: C file functions in QB64 ??? - by Petr - 04-26-2023, 01:25 PM
RE: C file functions in QB64 ??? - by Jack - 04-26-2023, 02:25 PM
RE: C file functions in QB64 ??? - by Kernelpanic - 04-28-2023, 05:02 PM
RE: C file functions in QB64 ??? - by Jack - 04-28-2023, 05:51 PM
RE: C file functions in QB64 ??? - by Jack - 04-28-2023, 06:50 PM
RE: C file functions in QB64 ??? - by Ultraman - 04-28-2023, 07:04 PM
RE: C file functions in QB64 ??? - by Kernelpanic - 04-28-2023, 07:50 PM
RE: C file functions in QB64 ??? - by DSMan195276 - 04-29-2023, 02:16 AM
RE: C file functions in QB64 ??? - by Kernelpanic - 04-29-2023, 06:58 PM



Users browsing this thread: 2 Guest(s)