Reading from a file?

Jeremy @ Cowgar jeremy at cowgar.com
Thu Jul 30 01:31:33 UTC 2009


Hello Lisaac,

  OK, this seems to work:

Section Header

  + name := TEST ;

Section Inherit

  - parent:OBJECT := OBJECT;

Section Public

  - main <-
  ( + entry:ENTRY;
    + file:STD_FILE;
    + buf:STRING;
    
    entry := FILE_SYSTEM.get_entry "test.li";
    (entry = NULL).if {
      STD_ERROR.put_string "Error: File test.li does not exist!\n";
      die_with_code exit_failure_code;
    };

    file ?= entry;
    (file = NULL).if {
      STD_ERROR.put_string "file is NULL";
      die_with_code exit_failure_code;
    };

    buf := STRING.create (file.size);
    (file.open = FALSE).if {
      STD_ERROR.put_string "file could not be opened.";
      die_with_code exit_failure_code;
    };

    file.read buf size (file.size);
    file.close;
    buf.println;
  );


Jeremy
mailto:jeremy at cowgar.com





More information about the Lisaac-devel mailing list