To use this file copy and paste this:
// #URL-lib "http://pin1.org/forthlib/flb/SD-Card/stage-4.fth" into BV Terminal 3
or here to download.
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// Creating and writing to files
// For this to work there must be files on the card with the same
// names as the ones used in this example
// Because fat-4 shares many words with fat-1,2,3 the SID numbers
// should be made the same, in other words fat-4 is an extension
// of fat-1,2,3
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// REQUIRES:
// #URL-lib "http://pin1.org/forthlib/flb/General/soft1.flb" sid=99
// #URL-lib "http://pin1.org/forthlib/flb/General/pinsel.flb" sid=100
// #URL-lib "http://pin1.org/forthlib/flb/General/SPI.flb" sid=101
// #URL-lib "http://pin1.org/forthlib/flb/SD-Card/MMC.flb" sid=102
// #URL-lib "http://pin1.org/forthlib/flb/General/rtc.flb" sid=103
// #URL-lib "http://pin1.org/forthlib/flb/SD-Card/fat-1.flb" sid=200
// #URL-lib "http://pin1.org/forthlib/flb/SD-Card/fat-2.flb" sid=200
// #URL-lib "http://pin1.org/forthlib/flb/SD-Card/fat-3.flb" sid=200
// #URL-lib "http://pin1.org/forthlib/flb/SD-Card/fat-4.flb" sid=200
//
// dump is used for debug and so is included in its entirity
// #URL-lib "http://pin1.org/forthlib/flb/General/dump.flb" sid=103
Full Contents of File
: start
    4000000  spi.speed 
    3  0  mmc.mount 
;
: dirf.ls  ;
   
: clr00  f.fb  512  0  fill  ; 
: clr200  f.fb  512  &20  fill  ; 
: s2
    s"  joe.txt"  0  f.create  -1  <>  abort"  file  creation  prblem"
;
: s2a
    s"  joe.txt"  0  f.open  -1  <>  abort"  file  cant  open  joe.txt"
;   
: s3
    clr0
    s"  This  is  to  sector  0  of  joe.txt" 
    0  f.fb  33  move 
    0  0  f.wrandom   
    clr0
    s"  This  is  to  sector  57  of  joe.txt"
    0  f.fb  33  move
    0  57  f.wrandom   
    0  f.close
;
: s4
    s"  joe.txt"  0  f.open 
    if
        cr  ."  SECTOR  0  "  cr
        0  0  f.rrandom  0=  if  0  f.fb  stype  then
        cr  ."  SECTOR  57  "  cr
        0  57  f.rrandom  0=  if  0  f.fb  stype  then
    else
        ."  cant  open  file"
    then       
;
: s5
    s"  joe.txt"  0  f.open
    if
        clr0
        s"  This  is  to  sector  64  of  joe.txt"
        0  f.fb  33  move
        0  64  f.wrandom   
        0  f.close
    else
        ."  cant  open  file"
    then       
;
: s6
    s"  joe.txt"  0  f.open
    if
        cr  ."  SECTOR  0  "  cr
        0  0  f.rrandom  0=  if  0  f.fb  stype  then
        cr  ."  SECTOR  57  "  cr
        0  57  f.rrandom  0=  if  0  f.fb  stype  then
        cr  ."  SECTOR  58  "  cr
        0  64  f.rrandom  0=  if  0  f.fb  stype  then
    else
        ."  cant  open  file"
    then       
;
: s8
    s"  joe.txt"  0  f.open  0=  abort"  Cant  open  file"
    67
    for
        clr0
        s"  Sector  "  0  f.fb  8  move 
        i  <#  #  #  #>  0  f.fb  10  +  2  move
        0  i  f.wrandom
        i  .
    next
    0  f.close
;
: s9
    s"  joe.txt"  0  f.open  0=  abort"  Cant  open  file"
    67
    for
        clr20   
        s"  Sector  "  0  f.fb  6  move 
        i  <#  #  #  #>  0  f.fb  8  +  2  move
        13  0  f.fb  11  +  c!   
        10  0  f.fb  12  +  c!   
        0  i  f.wrandom
        i  .
    next
    0  f.close
;                 
                 
: s17
    s"  joe.txt"  f.del
;