Latest OxygenBasic.zip at GitHub (Click on the Wizard)
0 Members and 1 Guest are viewing this topic.
' Read_Filestr.o2bas$ filename "Read_Filestr.exe"use rtl64'===================================FUNCTION readFileStr(gfnam AS STRING) AS STRING ' reads in the entire file as a string Long ff string bst ' IF ISFALSE ISFILE(gfnam) THEN ' File not found error -- we return a null string ' FUNCTION = "" ' EXIT FUNCTION ' END IF ff = 3 'FREEFILE OPEN gfnam FOR BINARY AS #ff GET$ #ff, LOF(ff), bst CLOSE #ff FUNCTION = bstEND FUNCTION '===========================================' Start of main string filnam , wfilstr filnam = "co2.exe" wfilstr = readFileStr(filnam)print " wanted file string : " + $CRLF + wfilstr
string s=GetFile "MyfileA.bin"PutFile s,"MyFileB.bin"
' Read_Filestr.o2bas$ filename "Read_Filestr.exe"use rtl64'===================================FUNCTION readFileStr(gfnam AS STRING) AS STRING ' reads in the entire file as a string Long ff string bst ' IF ISFALSE ISFILE(gfnam) THEN ' File not found error -- we return a null string ' FUNCTION = "" ' EXIT FUNCTION ' END IF ' ff = 3 'FREEFILE ' OPEN gfnam FOR BINARY AS #ff ' GET$ #ff, LOF(ff), bst ' CLOSE #ff bst = GetFile gfnam FUNCTION = bstEND FUNCTION '===========================================' Start of main string filnam string wfilstr filnam = "C:\oxygenBasic Compiler\bmt.dll" wfilstr = readFileStr(filnam)print " wanted file string : " + wfilstrprint " length of file string : " + str$(len(wfilstr))
print " wanted file string : " + $CRLF + wfilstr
$ crlf chr(13,10)'same as:% crlf chr(13,10)