GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Download
  • News
  • Community
  • Resources
  • Language Reference
  • SmallBASIC Manual

This view

  • Original page
  • New address

GeezerVison is showing smallbasic.github.io — SmallBASIC | EOF

Edit History

EOF

EOF (fileN)

Home > Reference > File

Returns true if the file pointer is at end of the file. For serial port (RS232) and TCP/IP socket connection EOF returns true if the connection is broken. For socket connection the return value ofEOF will be updated every time data is recieved or send.

Example 1: Reading data from a file

' create a text file
open "MyDemoFile.txt" for output as #1

for i = 1 to 10
    print #1, i 
next

close #1

' open text file and print content line by line
open "MyDemoFile.txt" for input as #1

while(!eof(1))   ' eof works only without #
    input #1, c
    print c
wend

close #1

Example 2: Reading from a TCP/IP socket

rem Print a date string like '29 SEP 2018 09:31:49 ACST'
func get_time
  local today = julian(date)
  local start = timer
  local t_hour, t_min, t_sec, t_str
  timehms start, t_hour, t_min, t_sec
  rem TODO, format should support multiple arguments
  t_str = format(" ##:", t_hour) + format("##:", t_min) + format("##", t_sec)
  return datefmt("dd mmm yyyy", today) + t_str
end

while 1
  open "SOCL:8080" as #1
  while (not eof(1))
    lineinput #1, s
    if (s == "time")
      print #1, get_time
    else
      print #1, "unknown command"
    endif
  wend
  close #1
wend
Code samples using EOF
3d_palmx.bas   4tune.bas   agendus.bas   coordplot.bas   demanda.bas   drawpoly.bas   duckduckgo.bas   form demo.bas   g2 Life.bas   g3 Life.bas   g4 Life.bas   g5 Life.bas   g6 Life.bas   gaptest.bas   irc-bot.bas   new help.bas   palm_cli.bas   palmcli.bas   screensv_ld_compres.bas   star worlds.bas   stars.bas   swirl2.bas   tabs2spaces.bas   TinyBASIC.bas   tracklog.bas   typewriter with sound effects.bas   typewriter.bas  
File
ACCESS   BGETC   BLOAD   BPUTC   BSAVE   CHDIR   CHMOD   CLOSE   COPY   DIRWALK   EOF   EXIST   FILES   FREEFILE   INPUT   INPUT   KILL   LOCK   LOF   MKDIR   OPEN   READ   RENAME   RMDIR   SEEK   SEEK   TLOAD   TSAVE   WRITE  
This page was last edited on Fri, 2 Feb 2024 23:03:29 +0100 | Markdown processed with pandoc 3.1.12.1
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.