\ 2006-12-03 EW adv3_redir.fs \ poor man's redirection \ (stdout, lcd, uart0) Variable 'type \ pointer to correct "type" Variable 'emit \ pointer to correct "emit" Variable 'cr \ pointer to correct "cr" : to-stdout ( -- ) ['] (type) 'type ! ['] (emit) 'emit ! ['] cr 'cr ! ; : to-lcd ( -- ) ['] lcdtype 'type ! ['] lcdemit 'emit ! ['] lcdcr 'cr ! ; : to-uart0 ( -- ) ['] uart0type 'type ! ['] uart0emit 'emit ! ['] uart0cr 'cr ! ; : >type ( -- ) 'type @ execute ; : >emit ( -- ) 'emit @ execute ; : >cr ( -- ) 'cr @ execute ; : +redir ( -- ) ['] >type is type ['] >emit is emit ; : -redir ( -- ) ['] (type) is type ['] (emit) is emit ; to-stdout \ default