Oxoscript turns into NanoPy - more infos

File functions

readLine

  readLine()->byte[256]

Reads a string (without ‘\n’) from the previously opened file.

open(C_READ, "my_file.txt")
while not eof():
    print(readLine())
close()

Note: A maximum of 255 characters can be read per call.

writeLine

  writeLine(line:byte[])

Writes a string + ‘\n’ to the previously opened file.

open(C_WRITE, "my_file.txt")
writeLine("Hello World!")
close()

fileExists

  fileExists(path:byte[])->bool

Returns true if the file exists in the file system.

eof

  eof()->int

A value greater than 0 (true) is returned if the end of file indicator was set. Otherwise 0 (false) is returned.

renameFile

  renameFile(path:byte[], newPath:byte[])

Renames the file defined with “path” to “newPath”.

renameFile("my_file.txt", "my_new_file.txt")

deleteFile

  deleteFile(path:byte[])

Deletes the file defined with “path”.

deleteFile("my_file.txt")

getFileSize

  getFileSize(path:byte[])->long

Returns the size of the file defined with “path” in number of bytes.

size = getFileSize("my_file.txt")

close

  close()

Closes the previously opened file.

close()

readFloat

  readFloat()->float

Reads a float value from the previously opened file.

open(C_READ, "my_file.txt")
val = readFloat()
close()

readLong

  readLong()->long

Reads a long value from the previously opened file.

open(C_READ, "my_file.txt")
val = readLong()
close()

readInt

  readInt()->int

Reads an int value from the previously opened file.

open(C_READ, "my_file.txt")
val = readInt()
close()

readByte

  readByte()->byte

Reads a byte value from the previously opened file.

open(C_READ, "my_file.txt")
val = readByte()
close()

read

  read()->byte

Reads a single character from the previously opened file.

open(C_READ, "my_file.txt")
text:byte[13] # to hold "Hello World!"
for i in 13:
  text[i] = read()
close()

writeFloat

  writeFloat(val:float)

Writes a float value to the previously opened file.

open(C_WRITE, "my_file.txt")
writeFloat(123.456)
writeFloat(-123.456)
close()

writeLong

  writeLong(val:long)

Writes a long value to the previously opened file.

open(C_WRITE, "my_file.txt")
writeLong(2147483647)
writeLong(-2147483647)
close()

writeInt

  writeInt(val:int)

Writes an int value to the previously opened file.

open(C_WRITE, "my_file.txt")
writeInt(32767)
writeInt(-32768)
close()

writeByte

  writeByte(val:byte)

Writes a byte value to the previously opened file.

open(C_WRITE, "my_file.txt")
writeByte(255)
close()

write

  write(val:byte)

Writes a single character to the previously opened file.

open(C_WRITE, "my_file.txt")
text = "Hello World!"
for c in text:
  write(c)
close()

open

  open(type:byte, path:byte[])

Opens the file defined with “path” for reading, writing or appending.

open(C_READ, "my_file.txt")
open(C_WRITE, "my_file.txt")
open(C_APPEND, "my_file.txt")