Skip to content

Version 1.9

Techcraft7 edited this page Dec 25, 2020 · 8 revisions

1.9

New syntax

  • import "<path to file[.7slib] OR some system lib.sys>"; import library

System libraries

random.sys

  • nextInt(int, int); next int within range
  • nextDouble(double, double); next double within range
  • next() random int
  • setSeed(int); set RNG seed
Example
import "random.sys";

loop (10) {
    write(nextInt(1, 10));
}

io.sys

  • readFile(path) - get a read stream to a file
  • writeFile(path) - get a write stream to a file
  • close(stream) - close stream, used to clean up resources. Not using this could cause a memory leak!
  • readByte(stream) - read a byte from stream
  • readText(stream, count, encoding = utf8) - read count charcters from stream
  • readLine(stream, encoding = utf8) - read from stream until \n or the end, will remove \r if it is the last character in the string
  • writeByte(stream, value) - write value to stream
  • writeText(stream, text, encoding = utf8) - write text to stream using encoding encoding
  • writeLine(stream, text, encoding = utf8) - same as writeText, but appends \n
Example
import "io.sys";

stream = writeFile("test.txt");

writeByte(stream, 42);
writeText(stream, "Hello!"); // Write Hello! to the stream
writeLine(stream, "Test :)", "ascii"); // Write Test :) followed by a \n (new line) as ASCII text

close(stream);

stream = readFile("test.txt");

write(readByte(stream)); // Read a byte
write(readText(stream, 6)); // Read 6 characters
write(readLine(stream, "ascii")); // Read from stream until \n or the end of the stream. Interpret the bytes from the stream as ASCII (defaults to UTF8)

close(stream);

Should output:

Hello!
Test :)

test.txt should contain "*Hello!Test :)" with a blank line after it

New Shell commands

  • export <path> export code in editor to 7slib file at <path>
Clone this wiki locally