From: Dirk B. <db...@us...> - 2006-01-13 17:50:41
|
Update of /cvsroot/win32forth/win32forth/doc/classes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26243/doc/classes Added Files: File.htm Log Message: Added documentation for the Accelerator table support and the file I/O classes --- NEW FILE: File.htm --- <html> <head> <meta http-equiv="Content-Language" content="en-gb"> <meta name="GENERATOR" content="dexh00"> <meta name="ProgId" content="FrontPage.Editor.Document"> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title> </title><style><!-- h1 { font-family: Tahoma; font-size: 24pt; font-weight: bold } h2 { font-family: Tahoma; font-size: 18pt; font-weight: bold } --> </style> </head> <body><h1 align="center"> <a href="mailto:win...@ya...?subject=DOC:Doc error in $Id: File.htm,v 1.1 2006/01/13 17:50:33 dbu_de Exp $"> <img border="0" src="../TELLUS.gif" align="left" width="32" height="32"></a> <img border="0" src="../FORTHPRO.gif" width="32" height="32"> Win32Forth</h1> <hr /><h1>Classes for File I/O </h1><hr /><a name="File"></a> <h2>File I/O class </h2><pre><b><a name="0">:Class File <Super Object </a></b></pre><p>File I/O class </p><pre><b><a name="0">:M Close: ( -- ) </a></b></pre><p>Close the file. </p><pre><b><a name="0">:M Open: ( -- f ) </a></b></pre><p>Open the file </p><pre><b><a name="0">:M Read: { addr cnt -- f } </a></b></pre><p>Read cnt bytes from the file into memory </p><pre><b><a name="0">:M Write: { addr cnt -- f } </a></b></pre><p>Write cnt bytes from memory into the file. </p><pre><b><a name="0">:M Create: ( -- f ) </a></b></pre><p>Create the file. </p><pre><b><a name="0">:M Delete: ( -- ) </a></b></pre><p>Delete the file </p><pre><b><a name="0">:M Rename: { addr cnt -- } </a></b></pre><p>Rename the file. </p><pre><b><a name="0">:M GetPosition: ( -- ud ) </a></b></pre><p>Get the position of the file pointer </p><pre><b><a name="0">:M RePosition: ( ud -- ) </a></b></pre><p>Set the position of the file pointer </p><pre><b><a name="0">:M FileSize: ( -- ud ) </a></b></pre><p>Get the size of the file </p><pre><b><a name="0">:M Append: ( -- ) </a></b></pre><p>Set append mode </p><pre><b><a name="0">:M Flush: ( -- ) </a></b></pre><p>Flush the file </p><pre><b><a name="0">:M ReadLine: ( addr len -- len eof ) </a></b></pre><p>Read a line from the file. </p><pre><b><a name="0">:M WriteLine: ( addr len -- ) </a></b></pre><p>Write a line to the file </p><pre><b><a name="0">:M Resize: ( ud -- ) </a></b></pre><p>Resize the file </p><pre><b><a name="0">:M Exist?: ( -- f ) </a></b></pre><p>Check if the file exist </p><pre><b><a name="0">:M SetName: ( addr cnt -- ) </a></b></pre><p>Set the file name </p><pre><b><a name="0">:M GetName: ( -- addr ) </a></b></pre><p>Get the file name </p><pre><b><a name="0">:M ClearName: ( -- ) </a></b></pre><p>Clear the file name </p><pre><b><a name="0">:M SetMode: ( mode -- ) </a></b></pre><p>Set the I/O mode </p><pre><b><a name="0">:M ErrorCode: ( -- n ) </a></b></pre><p>Get the error code of the previous file I/O </p><pre><b><a name="0">;Class </a></b></pre><p>End of File class </p><a name="ReadFile"></a> <h2>Class for loading/saving a complete file from/to memory </h2><pre><b><a name="0">:Class ReadFile <Super File </a></b></pre><p>ReadFile class for loading/saving a complete file from/to memory. </p><pre><b><a name="0">:M ReleaseBuffer: ( -- ) </a></b></pre><p>Free the memory of the file-buffer </p><pre><b><a name="0">:M GetBuffer: ( -- addr len ) </a></b></pre><p>Fet the address and len of the file-buffer </p><pre><b><a name="0">:M GetLength: ( -- len ) </a></b></pre><p>Get the length of the file-buffer </p><pre><b><a name="0">:M SetLength: ( len -- ) </a></b></pre><p>Set the length of the file-buffer. </p><p>NOTE: with this method you can set the length behind the allocated memory of the file-buffer! So take care. </p><pre><b><a name="0">:M SetBuffer: ( addr len -- ) </a></b></pre><p>Set the address and length of the file-buffer </p><pre><b><a name="0">:M AllocBuffer: ( len -- ) </a></b></pre><p>Allocate memory for the file-buffer </p><pre><b><a name="0">:M LoadFile: ( addr len -- f ) </a></b></pre><p>load a file into the file-buffer, f=true on success </p><pre><b><a name="0">:M SaveFile: ( -- ) </a></b></pre><p>Save the file-buffer to the file </p><pre><b><a name="0">;Class </a></b></pre><p>End of ReadFile class </p><h2>Example </h2><pre> ReadFile MyDumpFile : DumpFile ( addr len -- ) \ Load the file into memory LoadFile: MyDumpFile if \ get the address and length of the file buffer GetBuffer: MyDumpFile ( addr len ) \ do something with the file data dump \ don't forget to close the file Close: MyDumpFile else abort" Can't read file." then ; s" temp.f" DumpFile </pre><hr><p>Document $Id: File.htm,v 1.1 2006/01/13 17:50:33 dbu_de Exp $</p> </body></html> |