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 | LOF

Edit History

LOF

l = LOF (fileN)

Home > Reference > File

Returns the length l of a file with the file handle fileN in bytes. For other devices, returns the number of available data.

Example 1: Length of a file

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

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

close #1

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

FileLength = LOF(1)       ' lof works only without #

for ii = 1 to  FileLength 
    c = bgetc(1)
    print c
next

close #1

Example 2: Get available data for a socket connection

open "SOCL:10000" as #1     ' Open socket at port 10000

while (eof(1))              ' Loop until connection is closed

    l = lof(1)              ' Querry how much data is in the queue
    if(l) then              ' if data is available
        s = INPUT(l, #1)    ' get all data
        print s
    endif

wend

close #1
Code samples using LOF
anomail.bas   base64.bas   irc-bot.bas   palm_cli.bas   palmcli.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 Tue, 30 May 2023 15:32:29 +0200 | 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.