BCX Console Demonstration Program s77.bas

 DIM FileSize AS LONGLONG 
 DIM Junk
 
 IF COMMAND$ = "" THEN
   PRINT "Usage: S77 filename"
   END
 END IF
 
 DIM Buffer$ * LOF(COMMAND$) + 1
 
 FileSize = LoadFile(COMMAND$, Buffer$)
 
 COLOR 3, 0 : PRINT "LoadFile loaded", FileSize, " bytes into Buffer$"
 COLOR 7, 0 : INPUT "Press Enter to display contents of Buffer$", Junk
 CLS
 
 PRINT Buffer$
 
 FREE Buffer$
 
 FUNCTION LoadFile(Fname$, FnBuffer$) AS DWORD
   ' ------------------------------------------------------ 
   ' Assumes Fname$ is a valid FileName to an existing file 
   ' Assumes FnBuffer$ is large enough to hold entire file 
   ' ------------------------------------------------------- 
   DIM dwRead AS DWORD
   DIM H    AS HANDLE
   DIM Fsize AS LONGLONG
   Fsize = LOF(Fname$)
   H = CreateFile(Fname$, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0)
   IF H THEN
     ReadFile(H, FnBuffer$, Fsize, &dwRead, NULL)
     CloseHandle(H)
   END IF
   FUNCTION = dwRead
 END FUNCTION

Result:


 Result not displayed for this example.