Re: a new library
- Posted by neksys <i.shoot at REDNECKS.COM> Feb 05, 2000
- 316 views
THis looks pretty nice, I especially like the structures. I'm very interested in it, please, send it to RDS! Regards, Greg Bernie Ryan wrote: > I have a written a new library called mixedlib.e and if anyone is > interested in it, I will send it to RDS for distribution. > > The mixed library is a general pupose library that can be used to build > parsers, filters, macro or preprocessors, xbase file programs, games, etc. > and new features will be added if any interest grows in it's routines. > The future direction will be depend on users interests. > > The library features: > > Memory based ANSI "C" string handling > Standard "C" string routines > Demonstrates easier use of assembler > "C" string output from memory to device or file > Memory based structures that can be written to and from disk > "C" variable types > > The purpose of this library is to introduce the Euphoria programmer > to the techniques of using assembler and "C" code in a Euphoria Program. > I have used extensive comments in the library to help the Programmer to > understand what is happening in the library. The library is called the > mixed library because it is a mix of languages and has a mix of uses. > > The library's string handling routines are the same as "C" zero terminated > strings. The strings are NOT seqeunces but are memory based strings with > a zero terminating byte. The strings supported are the same as those used > by ANSI "C" and work the exact same way. This enables the programmer > to easily migrate "C" string applications to Euphoria. The structures are > declared in a form that makes it easy to forget about offsets. > > The latest version of Pete's ASM.E is required for the assembler routines. > This should be included with the mixedlib.e. Because the library is a > a general library it will be difficult to give extensive demos. The idea > is for the user to be creative enough to create the demos. > > This is an example of using strings ( just like "C" ) > > atom str1, str2, str3 > > str1 = string(255) -- create an empty string storage > str2 = string("Hello Euphoria") -- create an intialize string > str1 = strcpy(str1, str2) -- copy string2 to string1 > str1 = strupr(str1) -- convert str1 to all upper-case > > and so on just look in any "C" book and you see how to use them > > This is an example of using structures > > -- Allocate some structure pointers > pointer record1, record2 > > -- Define a record structure in high or low mmemory > -- the member can have any name, data type and size > > record1 = struc(" FName: string : 25 "& > " LName: string : 25 "& > " Age : byte : 1 "& > " Memo : string : 200 ", > HIGH) -- allocate in high memory > > Sets(record1, "Memo", "\nThis is a memo\n"& -- embed special characters > "and should be on\n"& -- or you can parse the field > "more than 1 line\n") -- using the string functions > > Sets(record1, "Age", 22) -- set age to 22 > > Sets(record1, "FName", "Sammy") -- set the structure's field > -- it will be truncated if > 25 > -- which was its declared size. > > record2 = dups(record1,LOW) -- duplicate the same record in > -- low memory > > cout(1,Gets(record2,"FName")) -- use cout to output null > -- terminated strings to any file > -- or device > > The structures can written in blocks to and from memory to a file > > Maybe one of you xbase experts could use it write a database > > Bernie