04-26-2023, 11:34 AM
using the msvcrt.dll helps to avoid type clashes, and although it compiles, it crashes
Code: (Select All)
Type file
ptr As _Offset 'zstring ptr
cnt As Long
bas As _Offset 'zstring ptr
flag As Long
file As Long
charbuf As Long
bufsiz As Long
tmpfname As _Offset 'zstring ptr
End Type
Declare Dynamic Library "msvcrt"
Function fopen%& (file_name As String, mode As String)
Function fclose& (file_ptr As _Offset)
Function fprintf& (file_ptr As _Offset, frmt As String, st As String)
End Declare
Dim As _Offset fp
Dim As String fln, md, frmt, text
Dim As Long status
'fp = _Offset(file)
fln = "fopen-test.txt" + Chr$(0)
md = "w" + Chr$(0)
frmt = "%s\n" + Chr$(0)
text = "hello world" + Chr$(0)
fp = fopen(fln, md)
Print "fp = fopen(fln, md) = "; fp
status = fprintf(fp, frmt, text)
status = fclose(fp)