\ io \ \ io_file_glue \ link between the file system and the rest of io via the screen components. \ \ \ see modules:io_file for more details on the file I/O used by io. \ \ see the file io_top for more information on io itself. \ \ \ constructor: Han-earl Park \ copyright 2008 buster & friends' C-ALTO Labs \ \ www.busterandfriends.com/io \ \ (Edinburgh, November 1996 - \ (London, August 1997 - \ (Den Haag, October 1997 - \ (Valencia, March 1999 - \ (Southampton, May 2000 - \ (Cork, April 2006 - \ \ (Cork, October 2008 - \ \ REV: 0.0.1 alpha (Southampton, October 2000) \ REV: 0.0.1 beta (Southampton, November 2000) \ REV: 0.0.1 alpha++ (Southampton, July 2004) \ REV: 0.0.1 beta++ (Cork, May 2010) \ \ \ REV: 0.0.1 alpha * Unused * \ REV: 0.0.1 beta * Unused * \ MOD: HeP 04-11-04 Add the io_file_gui component. \ MOD: HeP 04-12-04 Implement most of the words. \ Renames of these words so they are prefixed by "FILE->" or \ suffixed by "->FILE". \ Tested reading and writing all supported data. \ MOD: HeP 04-13-04 Renamed io_file_screen_link. \ MOD: HeP 04-15-04 Renamed (again) as io_file_link. \ MOD: HeP 04-30-04 Renamed (yet again) as io_file_glue. \ MOD: HeP 05-17-04 Rewrite some of the remaining words from io_screen so we \ can call them here without problems. This fixes a bug that \ set UNSAVED.CHANGES? to true when switching scenes. \ REV: 0.0.1 a ++ __________________________________________________________ \ REV: 0.0.1 b ++ __________________________________________________________ \ Version for performance at Blackrock Castle Observatory, \ Cork, Ireland, May 25, 2010. anew task-io_file_glue \ output : FILE->OUTPUT.DEVICE ( type -- ) dup 0 many: output-device-grctrl within? IF true swap 2dup put.value: output-device-grctrl (output.device.grfunc) \ n pt# -- ELSE drop THEN ; : OUTPUT.DEVICE->FILE ( -- type ) many: output-device-grctrl 0 DO i get.value: output-device-grctrl IF i LEAVE THEN LOOP ; : FILE->OUTPUT.CHANNEL ( n -- ) dup 1 16 within? IF 0 2dup put.value: output-chan-grctrl (output.chan.grfunc) \ n pt# -- ELSE drop THEN ; : OUTPUT.CHANNEL->FILE ( -- n ) 0 get.value: output-chan-grctrl ; : FILE->OUTPUT.DEVICE.ID ( n -- ) vl_instr get.value: output-device-grctrl IF dup 1 16 within? IF 1 2dup put.value: output-chan-grctrl (output.chan.grfunc) \ n pt# -- ELSE drop THEN ELSE drop THEN ; : OUTPUT.DEVICE.ID->FILE ( -- n ) 1 get.value: output-chan-grctrl ; : FILE->OUTPUT.PAN ( flag -- ) vl_instr get.value: output-device-grctrl gm_instr get.value: output-device-grctrl OR IF 0 2dup put.value: output-panrev-grctrl (output.panrev.grfunc) \ flag pt# -- ELSE drop THEN ; : OUTPUT.PAN->FILE ( -- flag ) 0 get.value: output-panrev-grctrl ; : FILE->OUTPUT.REV ( flag -- ) vl_instr get.value: output-device-grctrl gm_instr get.value: output-device-grctrl OR IF 1 2dup put.value: output-panrev-grctrl (output.panrev.grfunc) \ flag pt# -- ELSE drop THEN ; : OUTPUT.REV->FILE ( -- flag ) 1 get.value: output-panrev-grctrl ; \ input : INPUT.#ENABLED->FILE ( -- n, number of enabled parsers ) 0 io_#input 0 DO i 3 * get: input-grctrl-holder 0 swap get.value: [] + LOOP ABS ; : FILE->INPUT.ENABLED? ( indx flag -- ) over 0 io_#input 1- within? IF 0 \ -- indx flag pt# rot 3 * get: input-grctrl-holder \ -- flag pt# obj 3dup put.value: [] (input.enable.grfunc) \ flag pt# obj -- ELSE 2drop THEN ; : INPUT.ENABLED?->FILE ( indx -- flag ) 3 * get: input-grctrl-holder 0 swap get.value: [] ; : FILE->INPUT.DEVICE ( indx type -- ) over 0 io_#input 1- within? IF true swap \ -- indx flag pt# rot 3 * 1+ get: input-grctrl-holder \ -- flag pt# obj \ 2dup many: [] 1- 0 swap within? \ supported parser type? IF 3dup put.value: [] (input.device.grfunc) \ flag pt# obj -- ELSE 3drop THEN ELSE 2drop THEN ; : INPUT.DEVICE->FILE ( indx -- type ) 3 * 1+ get: input-grctrl-holder dup many: [] 0 DO i over get.value: [] IF drop i LEAVE THEN LOOP ; : FILE->INPUT.CHANNEL ( indx chan -- ) over 0 io_#input 1- within? over 1 16 within? AND IF 0 \ -- indx chan pt# rot 3 * 2+ get: input-grctrl-holder \ -- chan pt# obj 3dup put.value: [] (input.chan.grfunc) \ n pt# obj -- ELSE 2drop THEN ; : INPUT.CHANNEL->FILE ( indx -- chan ) 3 * 2+ get: input-grctrl-holder 0 swap get.value: [] ; : FILE->INPUT.BEND ( indx bend -- ) over 0 io_#input 1- within? over 0 24 within? AND IF 1 \ -- indx chan pt# rot 3 * 2+ get: input-grctrl-holder \ -- chan pt# obj 3dup put.value: [] (input.chan.grfunc) \ n pt# obj -- ELSE 2drop THEN ; : INPUT.BEND->FILE ( indx -- bend ) 3 * 2+ get: input-grctrl-holder 1 swap get.value: [] ; \ ui : FILE->UI.CTRL ( mode -- ) dup 0 2 within? IF true swap 2dup put.value: ui-ctrl-grctrl (ui.ctrl.grfunc) \ n pt# -- ELSE drop THEN ; : UI.CTRL->FILE ( -- mode ) many: ui-ctrl-grctrl 0 DO i get.value: ui-ctrl-grctrl IF i LEAVE THEN LOOP ; : FILE->UI.CHANNEL ( n -- ) dup 1 16 within? IF dup 0 put.value: ui-chan-grctrl io.ui.chan#! ELSE drop THEN ; : UI.CHANNEL->FILE ( -- n ) 0 get.value: ui-chan-grctrl ; : FILE->UI.C1 ( n -- ) dup 1 127 within? IF dup 1 put.value: ui-chan-grctrl io.ui.c1! ELSE drop THEN ; : UI.C1->FILE ( -- n ) 1 get.value: ui-chan-grctrl ; : FILE->UI.C2 ( n -- ) dup 1 127 within? IF dup 2 put.value: ui-chan-grctrl io.ui.c2! ELSE drop THEN ; : UI.C2->FILE ( -- n ) 2 get.value: ui-chan-grctrl ; \ performance duration : FILE->PDUR ( seconds -- ) [ 60 60 * 1- ] literal MIN \ clip to less than one hour \ 60 /mod 1 put.value: pdur-time-grctrl 2 put.value: pdur-time-grctrl \ (pdur.store.value) \ -- ; : PDUR->FILE ( -- seconds ) 1 get.value: pdur-time-grctrl 60 * 2 get.value: pdur-time-grctrl + ; : FILE->PDUR.MODE ( mode -- ) dup 0 2 within? IF true swap 2dup put.value: pdur-mode-grctrl (pdur.mode.grfunc) \ n pt# -- ELSE drop THEN ; : PDUR.MODE->FILE ( -- mode ) many: pdur-mode-grctrl 0 DO i get.value: pdur-mode-grctrl IF i LEAVE THEN LOOP ;