Go backward to Initialization for I/O.
Go up to Adding Input and Output Routines.
Go forward to Input functions.
Symbols
-------
Your input functions will want to add working memory elements to Soar's
working memory. To add a wme, you first need to create (or otherwise obtain)
the three symbols it contains: its id, attribute, and value. You should
create symbols by using any of the following function calls:
Symbol *up_sym, *the_answer_sym, *pi_sym, *id_sym;
up_sym = get_io_sym_constant ("up");
the_answer_sym = get_io_int_constant (42);
pi_sym = get_io_float_constant (3.1416);
id_sym = get_new_io_identifier ('I');
The last function call creates a new identifier which starts with the letter
I, e.g., I36. You can also get the (already existing) identifier of the
current top state by reading the global variable top_state.
Once you're done using a symbol (i.e., your code won't need the Symbol * any
more), you must "release" it:
release_io_symbol (up_sym);
release_io_symbol (the_answer_sym);
release_io_symbol (pi_sym);
release_io_symbol (id_sym);
However, do *not* release a symbol if you have stored it (as a Symbol *)
within a data structure in your I/O code. Also, do *not* release the
top_state. Only release symbols you obtained via a call to one of the
get_io_such-and-such() routines above.