-
Notifications
You must be signed in to change notification settings - Fork 4
Version 1.9
Techcraft7 edited this page Dec 25, 2020
·
8 revisions
-
import "<path to file[.7slib] OR some system lib.sys>";import library
-
nextInt(int, int);next int within range -
nextDouble(double, double);next double within range -
next()random int -
setSeed(int);set RNG seed
import "random.sys";
loop (10) {
write(nextInt(1, 10));
}-
readFile(path)- get a read stream to a file -
writeFile(path)- get a write stream to a file -
close(stream)- closestream, used to clean up resources. Not using this could cause a memory leak! -
readByte(stream)- read a byte fromstream -
readText(stream, count, encoding = utf8)- readcountcharcters fromstream -
readLine(stream, encoding = utf8)- read fromstreamuntil \n or the end, will remove \r if it is the last character in the string -
writeByte(stream, value)- writevaluetostream -
writeText(stream, text, encoding = utf8)- writetexttostreamusing encodingencoding -
writeLine(stream, text, encoding = utf8)- same aswriteText, but appends\n
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
-
export <path>export code in editor to 7slib file at<path>
