' This is a sample showing how to write a file
' using ScriptBasic
'
on error goto ErrorLabel

const nl = "\r\n"

' Create a RAM file called xxx.txt
' The variable fn is automatically assigned a file number
fn = 0
open "xxx.txt" for output as fn

' Now write something to the file
'
print #fn, "This is a test file generated by ScriptBasic", nl
print #fn, "This is the last line", nl
close fn

' We now have a RAM file called xxx.txt.
' To save it to a permanent flash file we use the system
' move command, which copies the RAM file to a flash file,
' then deletes the ramfile
'
a = system("move xxx.txt ftest.txt")
print nl, "system command returned ", a, nl

' wait for flash write operation to complete
'
sleep(10)

print nl, "File ftest.txt saved to flash", nl
stop

ErrorLabel:
print "An Error occured: ", error$, "\r\n"
