Hi DSMan195276
you were right, byval fixed it
I should have seen it, it was there right in front of me
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
it displays hello world
you were right, byval fixed it
I should have seen it, it was there right in front of me
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
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