implementation module scrapuse;

import	StdClass, StdInt, StdChar, StdString, StdArray;
from	ioState import :: IOState ; // , IOStateGetToolbox, IOStateSetToolbox;

IOPutScrap :: !{#Char} !(IOState s) -> IOState s;
IOPutScrap string io
	= io;
/*
	= io2;
	{
		(tb,io1)	= IOStateGetToolbox io;
		(_,tb1)		= ZeroScrap tb;
		(_,tb2)		= PutScrapText string tb1;
		io2			= IOStateSetToolbox tb2 io1;
	}
*/

IOGetScrap :: !(IOState s) -> (!{#Char},!IOState s);
IOGetScrap io
	= ("",io);
/*
	| handle==0
		= ("",IOStateSetToolbox tb0 io1);
	| size<=0
		= ("",IOStateSetToolbox tb2 io1);
		{
			(_,tb2)	= DisposHandle handle tb1;
		}
		= (string,IOStateSetToolbox tb3 io1);
		{
			(string,tb2)= handle_to_string handle size tb1;
			(_, tb3)	= DisposHandle handle tb2;
		}
	{
		(tb,io1)		= IOStateGetToolbox io;
		(handle,_,tb0)	= NewHandle 0 tb;
		(size,_,  tb1)	= GetScrap handle TextResourceType tb0;
	}

handle_to_string :: !Handle !Int !*Toolbox -> (!{#Char},!*Toolbox);
handle_to_string handle size tb0
	=	(string,tb1);
	{
		tb1		= copy_handle_data_to_string string handle size tb0;
		string	= createArray size ' ';
	}
/* RWS
copy_handle_data_to_string :: !{#Char} !Handle !Int !*Toolbox -> *Toolbox;
copy_handle_data_to_string string handle size tb = code (string=U,handle=D1,size=D2,tb=U)(z=Z){
	instruction 0x80640000	|	lwz		r3,0(r4)
	instruction 0x38970008	|	addi	r4,r23,8	
	call	.BlockMoveData
}
*/

*/
