[go: up one dir, main page]

Menu

[r4]: / LoadFile.spin  Maximize  Restore  History

Download this file

61 lines (40 with data), 1.1 kB

{{

  This demonstrates the use of the Find, and Load methods.  The Find method is used to locate a file header
  by file name.  If the file header is located, the Find method will return true, otherwise false.
  Load will load the file contents into a buffer that you specify.

  Usage:

        Success := EEFS.Find(fileNamePtr)
        EEFS,Load(@bufferPtr)

}}

CON

        _clkmode        = xtal1 + pll8x
        _xinfreq        = 10_000_000 


VAR
  long  Buffer[256]

OBJ

  tv      : "tv_terminal_010.spin"
  EEFS    : "JGP_EEFileSystem_001"

PUB Start

  bytefill(@Buffer, 0, 256)

  tv.start
  tv.start
  if !EEFS.Start(28, 29,500)
    EEFS.CriticalError

  writeln(string("Load a file"))
  tv.out(13)
  tv.out(13)

  tv.pstring(string("Loading "))
  writeln(@FileName)
  tv.out(13)
  
  if EEFS.Find(@FileName)
    EEFS.Load(@Buffer)    
    writeln(string("File Contents"))
    writeln(@Buffer)
  else
    writeln(string("Not found"))

  repeat

PRI writeln(stringPtr)

  tv.pstring(stringPtr)
  tv.out(13)

DAT

        FileName        byte "Story 2",0