Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // class init:
- FILES = [];
- index = 0;
- FILES[index] = void
- // class functions:
- func open(file, ...):
- ff = fopen(vargs(1), vargs(2))
- return ff
- end
- func close(file, ...):
- fclose(file)
- return file
- end
- func write(file, ...):
- fwrite(file, vargs(1))
- return file
- end
- // main class:
- func file(op, ...):
- FILES[index] = op(FILES[index], vargs(1), vargs(2))
- return FILES[index]
- end
- // using the class
- file(open, "1.txt", "w")
- file(write, "file 1")
- file(write, "\nA text.")
- file(close)
- // the index was 0, means we were manipulating FILES[0]
- index = 1;
- // now we are manipulating FILES[1]
- file(open, "2.txt", "w")
- file(write, "file 2")
- file(write, "\nA text.")
- file(close)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement