Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. // class init:
  2.  
  3. FILES = [];
  4. index = 0;
  5. FILES[index] = void
  6.  
  7. // class functions:
  8.  
  9. func open(file, ...):
  10.    ff = fopen(vargs(1), vargs(2))
  11.    return ff
  12. end
  13.  
  14. func close(file, ...):
  15.    fclose(file)
  16.    return file
  17. end
  18.  
  19. func write(file, ...):
  20.    fwrite(file, vargs(1))
  21.    return file
  22. end
  23.  
  24. // main class:
  25.  
  26. func file(op, ...):
  27.    FILES[index] = op(FILES[index], vargs(1), vargs(2))
  28.    return FILES[index]
  29. end
  30.  
  31. // using the class
  32.  
  33. file(open, "1.txt", "w")
  34. file(write, "file 1")
  35. file(write, "\nA text.")
  36. file(close)
  37.  
  38. // the index was 0, means we were manipulating FILES[0]
  39. index = 1;
  40. // now we are manipulating FILES[1]
  41. file(open, "2.txt", "w")
  42. file(write, "file 2")
  43. file(write, "\nA text.")
  44. file(close)