Manipulators Module =================== © 1996 Michael Sparks A manipulator is a list of pairs correspding to those in a two column table. The rows themselves that form the pairs are stored as short lists. ie IN | OUT ========= 1 | "one" 2 | "two" 3 | "three" 4 | "four" becomes [ [1, "one"], [2, "two"], [3, "three"], [4, "four"] ] So what eh? Well, the function info2data() allows you to search the first column, and it will return the contents of the second column. If the search column is not a number then you must supply a comparison function to test two such items of the same type for equality. eg: (not complete!) PROC str_cmp(a,b) IS StrCmp(a,b) -> Can't get the address of a standard E-Function! PROC main() WHILE (input>0) AND (notquit) func:=info2data(input, [ ["forward",{forward}], ["back", {back}], ["left", {left}], ["right", {right}], ["quit", -2] ], {str_cmp}) IF func>0 func() ELSE IF func=-2 THEN notquit:=FALSE ENDIF ENDWHILE ENDPROC ... and so on. This is not an example program, but is is an outline of one! For a better example use of this, see the paint program! Syntax: lw(a:PTR TO list) Checks to see if a list really is a list - ie is unifiable. info2data(search_value, list_to_search, comparison_function_pointer=NIL) searchs the list given for a pair containing the search value in the first field, and returns the data stored in the second field. If a comparison function is supplied, then it will be used to compare the search value with that in the first field of each pair. NOTE that this procedure ONLY returns the first such value in the list! This is all I am prepared to document in this version, and this is definately subject to change, so there! Even so, these two are very useful. Look at the paint program if you need convincing of this.