:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: : class Io.Utility.Public public Gilda: Utilities for performing data I/O. global +Text.Clip Heap..string, &Lines of selected text +Text.End Bit :0 if no return after the last line : Make this a structure??? : global +File, &File Id being searched??? +At.Buffer At..byte, &Current file buffer. +Size word, &Size of the buffer. +Offset word, &Offset into the buffer (Length when done). +C1 byte, &Character to find, +C2 byte :Second to find; if no second set to C1. : : io/crc/Crc.Word Compute a 32 bit CRC checksum. : io/log/Message.Log Create a single log file. : io/serialize/Serialize.Primitive Serialize and deserialize primitive types. : io/clip/Text.Clip Manage the state of a system clipboard. : io/raw/Raw.Io Utilities to assist in raw I/O operations : io/raw/Search.File Scan a file for any of a set of bytes. :............................................................................... :::::::::::::::::::::::::::::: io/crc/Crc.Word ::::::::::::::::::::::::::::::: : function CRC..string: Compute the CRC checksum of a string. entry Data string, &User data to fold into the CRC Prior = -1 word :CRC prior to this point exit Crc word :Updated CRC : :............................................................................... : function CRC..cell: Compute the CRC checksum of a 64 bit integer. entry Data cell, &User data to fold into the CRC Prior = -1 word :CRC prior to this point exit Crc word :Updated CRC : :............................................................................... : function CRC..word: Compute the CRC checksum of a 32 bit integer. entry Data word, &User data to fold into the CRC Prior = -1 word :CRC prior to this point exit Crc word :Updated CRC : :............................................................................... : function CRC..parcel: Compute the CRC checksum of a 16 bit integer. entry Data parcel, &User data to fold into the CRC Prior = -1 word :CRC prior to this point exit Crc word :Updated CRC : :............................................................................... : function CRC..byte: Compute the CRC checksum of a byte. entry Data[*Max] byte, &User data to fold into the CRC Prior = -1 word :CRC prior to this point exit Crc word :Updated CRC : :............................................................................... ::::::::::::::::::::::::::::: io/log/Message.Log ::::::::::::::::::::::::::::: : method OPEN.LOG: Open the log file. entry File string, &OS path of the log file. Silent = 0 Bit, &0 - Write messages to Standard Error as well. &1 - Only write messages to the log file. Append = 0 Bit :Append messages if a log file exists. precondition @Log`Id = 0 error File; The log file is already open. . :............................................................................... : method CLOSE.LOG: Close the log file. : :............................................................................... : method RESET.SILENT: Enable or disable writing messages to Standard Error. entry Silent = 0 Bit :0 - Also write to Standard Error. :1 - Only log the message. :............................................................................... : method APPEND.LOG: Open a log file, write a message, and close it. entry File string, &OS path of the log file. Message = "" string, &Message text; no trailing return is needed. Silent = 0 Bit :0 - Write messages to Stdandard Error as well. :1 - Only write messages to the log file. :............................................................................... : method PRINT.LOG: Write a message to a log file and optionally to Standard Error. entry Message = "" string, &Message text; no trailing return is needed. More = 0 Bit :1 - Supress inserting a trailing return. : : Note: Set More when you want to make a series of calls : to concatenate a message. :............................................................................... : method PRINT.ERROR: Also write to Standard Error even if silent running. entry Message = "" string :Message text; no trailing return is needed. : :............................................................................... : method POST.LOG pure: See if an I/O error occured while logging. exit Status byte :0 if no error; else an I/O error code. : :............................................................................... :::::::::::::::::::: io/serialize/Serialize.Primitive :::::::::::::::::::::::: : function SERIALIZE..string: Serialize a string. entry String :User data to serialize exit Serial string :A quoted string enclosed in double quotes : :............................................................................... : method DESERIALIZE..string: Deserialize a string. exit String :Deserialized user data entry Serial string :A quoted string enclosed in double quotes precondition byte{ Serial } = '"' fault Serial; A serialized string must be quoted. . :............................................................................... : function SERIALIZE..byte: Serialize an 8 bit integer. entry Byte :User data to serialize exit Serial string :A lead ('p' | 'm') sign and upper case hex digits : :............................................................................... : method DESERIALIZE..byte: Deserialize an 8 bit integer. exit Byte :Deserialized user data entry Serial string :A lead ('p' | 'm') sign and upper case hex digits precondition byte{ Serial } = 'p' | 'm' fault Serial; Missing lead 'p' or 'm'. . :............................................................................... : function SERIALIZE..parcel: Serialize a 16 bit integer. entry Parcel :User data to serialize exit Serial string :A lead ('p' | 'm') sign and upper case hex digits : :............................................................................... : method DESERIALIZE..parcel: Deserialize a 16 bit integer. exit Parcel :Deserialized user data entry Serial string :A lead ('p' | 'm') sign and upper case hex digits precondition byte{ Serial } = 'p' | 'm' fault Serial; Missing lead 'p' or 'm'. . :............................................................................... : function SERIALIZE..word: Serialize a 32 bit integer. entry Word :User data to serialize exit Serial string :A lead ('p' | 'm') sign and upper case hex digits : :............................................................................... : method DESERIALIZE..word: Deserialize a 16 bit integer. exit Word :User data to serialize entry Serial string :A lead ('p' | 'm') sign and upper case hex digits precondition byte{ Serial } = 'p' | 'm' fault Serial; Missing lead 'p' or 'm'. . :............................................................................... : function SERIALIZE..cell: Serialize a 64 bit integer. entry Cell :User data to serialize exit Serial string :A lead ('p' | 'm') sign and upper case hex digits : :............................................................................... : method DESERIALIZE: Deserialize a 64 bit integer. exit Cell :Deserialized user data entry Serial string :A lead ('p' | 'm') sign and upper case hex digits precondition byte{ Serial } = 'p' | 'm' fault Serial; Missing lead 'p' or 'm'. . :............................................................................... : function SERIALIZE..double: Serialize a double precision IEEE floating point number. entry Double :User data to serialize exit Serial string :Serialized as: ['-'] '#1.' hex ['p' hex] : :............................................................................... : method DESERIALIZE..double: Deserialize a double precision IEEE floating point number. exit Double :Deserialized user data entry Serial string :Real number in Gilda hexadecimal format : :............................................................................... : function SERIALIZE..single: ed ed Serialize a single precision IEEE floating point number. entry Single :User data to serialize exit Serial string :Serialized as: ['-'] '#1.' hex ['p' hex] : :............................................................................... : method DESERIALIZE..single: Deserialize a single precision IEEE floating point number. exit Single :Deserialized user data entry Serial string :Real number in Gilda hexadecimal format : :............................................................................... ::::::::::::::::::::::::::::: io/clip/Text.Clip :::::::::::::::::::::::::::::: : method GET.TEXT.LINE: Get a single line of printable characters. exit Text string :Validated line. Null if none, more than one line, :or the text has non-printable characters. : :............................................................................... : method INSERT_TEXT_CLIP: Get text from the system clipboard. entry Clip[*] byte :Reference data in the system clipboard to insert. : :............................................................................... : method COPY_TEXT_CLIP: Copy the editor text buffer to the system clipboard. exit Clip[*] byte :Return text here to the system clipboard. : :............................................................................... :::::::::::::::::::::::::::::: io/raw/Raw.Io ::::::::::::::::::::::::::::::::: : method OPEN.STRING.OFFSET: Begin reading strings with random access. entry File string, &Os path of a file to open. Offset = 0 cell :Place in the file to start reading. : :............................................................................... : method CLOSE.STRING.OFFSET: Close direct access strings. : :............................................................................... : method READ.STRING.OFFSET: Begin reading strings with random access. exit Text = "" string, &A line of text; Empty if at End Of File. Offset cell :File offset to the first Byte in the line. :On End Of File, the size of the file. : :............................................................................... : method WRITE.STRING.OFFSET: Write a string with direct access. entry Text string, &A line of text to write. Offset cell :File offset to the first Byte in the line. : :............................................................................... ::::::::::::::::::::::::::::: io/raw/Search.File ::::::::::::::::::::::::::::: : method SEARCH.FILE.RAW: Find raw characters. entry File string :Os path name of the file (tame, readable). exit Line string, &Line containing the match; null if none. Index word :Index to first match; 0 if text miss; : -1 if not a text file. : :............................................................................... : method SEARCH.FILE.NEXT: Scan a file for any one of a set of characters. change Line string, & in - prior line being scanned. Null to move on. &out - Line containing a match or null if no match. Index word : in - Index to the last hit; junk if null Line. :out - Index to the match; 0 if no match. exit New Bit :1 - Advanced to another line. : :............................................................................... : method SEARCH.FILE.TEXT: See if a file is a text file and find characters. entry File string :Os path name of the file (tame, readable). exit Line = "" string, &Line containing the match; null if none. Index = -1 word :Index to first match; 0 if text miss; : -1 if not a text file. : :............................................................................... : method SEARCH.FILE.CLOSE: Terminate a search before scanning the whole file. : :............................................................................... end