GLBasic forum

Main forum => Bug Reports => Topic started by: fuzzy70 on 2011-Nov-09

Title: ENDOFFILE() example missing from the help file
Post by: fuzzy70 on 2011-Nov-09
ENDOFFILE() from the online help is missing its example

Code (glbasic) Select
// Files
test$ = "test.bin"
OPENFILE(1, test$, FALSE)

WRITEBYTE 1, 42
WRITEBYTE 1, -42
WRITEWORD 1, 16767
WRITEWORD 1, -16767
WRITEIEEE 1, 1.234E-4

xx$= "Hello World\nYes, Hello\n"
WRITESTR  1, xx$
WRITELONG 1, 16767
WRITELONG 1, -16767
CLOSEFILE 1

LOCAL b1%, b2%, w1%, w2%, l1%, l2%, ieee
LOCAL x2$, _x1$, _x2$
OPENFILE(1, test$, TRUE)
READBYTE 1, b1
READBYTE 1, b2
READWORD 1, w1
READWORD 1, w2
READIEEE 1, ieee

// READSTR 1, x2$, LEN(xx$)
READLINE 1, _x1$
READLINE 1, _x2$
READLONG 1, l1
READLONG 1, l2
CLOSEFILE 1

LOCAL i%
PRINT "b1="+b1, 0,i); INC(i, 10);
PRINT "b2="+b2, 0,i); INC(i, 10);
PRINT "w1="+w1, 0,i); INC(i, 10);
PRINT "w2="+w2, 0,i); INC(i, 10);
PRINT "ie="+ieee, 0,i); INC(i, 10);
PRINT "st="+_x1 + "-" + _x2, 0,i); INC(i, 10);
PRINT "l1="+l1, 0,i); INC(i, 10);
PRINT "l2="+l2, 0,i); INC(i, 10);

SHOWSCREEN
MOUSEWAIT


OPENFILE(1, "test.txt", FALSE)
WRITELONG 1, 1234
WRITELONG 1, 5678
WRITELONG 1, 9911
CLOSEFILE 1

LOCAL i

// 1234
OPENFILE(1, "test.txt", TRUE)
DEBUG "pos(0)="+FILEPOSITION(1)+"\n"
READLONG 1,i%; DEBUG "read="+i+"\n"

// 1234
FILESEEK(1, 0, 0)
DEBUG "pos(0)="+FILEPOSITION(1)+"\n"
READLONG 1,i%; DEBUG "read="+i+"\n"

// 1234
FILESEEK(1, -4, 1)
DEBUG "pos(0)="+FILEPOSITION(1)+"\n"
READLONG 1,i%; DEBUG "read="+i+"\n"

// 1234
FILESEEK(1, -12, -1)
DEBUG "pos(0)="+FILEPOSITION(1)+"\n"
READLONG 1,i%; DEBUG "read="+i+"\n"

// 9911
FILESEEK(1, 4, 1)
DEBUG "pos(0)="+FILEPOSITION(1)+"\n"
READLONG 1,i%; DEBUG "read="+i+"\n"

CLOSEFILE 1



As you can see there is no ENDOFFILE() command in the example in the help file

I worked out how to use it but might be a good idea to correct the help file for people that are new to GLB