void load_script(Block* block, const char* filename) { // Store the filename set_string(block_insert_property(block, s_filename), filename); // Read the text file circa::Value contents; circa_read_file(block->world, filename, &contents); if (is_null(&contents)) { Value msg; set_string(&msg, "File not found: "); string_append(&msg, filename); Term* term = create_string(block, as_cstring(&msg)); apply(block, FUNCS.error, TermList(term)); return; } parse(block, parse_statement_list, &contents); // Make sure the block has a primary output. if (get_output_placeholder(block, 0) == NULL) append_output_placeholder(block, NULL); update_static_error_list(block); return; }
void file__read_text(caStack* stack) { circa_read_file(circa_string_input(stack, 0), circa_output(stack, 0)); }