June 01, 2024, 05:07:06 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Aurora Common Classes

Started by Zen, January 06, 2006, 11:26:04 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Parker

The registry class is fully functional, it'll be in the next update.

This code creates the _100 extention for files, registers it with the Aurora IDE, and sets the "FirstValue" in that key to say "Hello there". Then it reads that value.
global sub main()
{
Registry r;
string value;
unsigned int type;

r.CreateKey(CCL_HKCR, "._100");
r.SetValue("FirstValue", "Hello there");
r.SetValue("", "Aurora");
r.CloseKey();

r.OpenKey(CCL_HKCR, "._100");
r.GetValue("FirstValue", value, CCL_LEN_STRING, type);
// You have to tell the function what length the value can hold.
// For a string, this is CCL_LEN_STRING.
// For a dstring, it is whatever was specified in the [] brackets.
// The "type" receives what type the value is. In this case, we only want a REG_SZ (CCL_REG_SZ)

if (type = CCL_REG_SZ) writeln(value) else writeln("Unknown type...");

while (GetKey() = "");
}

Parker

Basic threading is done too, and Lewis says he's almost ready for another update. Registry and Threading are basically wrappers around the Windows API functions that I never bothered to learn until now, that I hope someone else will find easier to use than the API. I use optional parameters ;)

Anyways, here's the example:
global sub main()
{
unsigned int h1 = ThreadStart(&thread1), h2 = ThreadStart(&thread2);
ThreadWait(h1, CCL_INFINITE);
ThreadWait(h2, CCL_INFINITE);
if ((ThreadExitCode(h1) = 0) and (ThreadExitCode(h2) = 1)) writeln("Got correct exit codes\n");
writeln("Threads have finished...");
while (GetKey() = "");
}


Piping and service will be a bit more than wrappers, I'm hoping they'll be done by the end of the week.

Ionic Wind Support Team

Keep up the good work.

When I get a bit more time I'll have to make a list of all planned classes on my end so we don't have any naming conflicts.  I generally name my classes with a prepended C. 

Ionic Wind Support Team

Parker

Thanks. Mine don't have a C in front of them, I think that convention comes from MFC which I've never used.

My list of classes includes
List (wrapper for some functions, this can't change because I use those functions rather than the class. The functions are duplicates of IB's ones, with a couple additions. And I didn't copy the source, I wrote them myself.)
Stack
Queue (this and stack might change how they work, right now they're just emulation through linked lists)
Dictionary
Command Line
Registry
Threading (it's not a class though, since there's no use)
Piping (not yet done)
Windows service (not yet done)
Binary tree dictionary (probably will be faster than current linked list Dictionary, but I haven't started it yet)
-- All of Lewis's classes, I'm not sure exactly
I have thought about doing a simple lexer class for anyone wanting to create a simple script language or something like that, maybe...

And there will probably be a few more misc functions to help.

Also I'm writing a utility that is much easier to use to compile source files, although it may not be finished until the info I had asked about is finalized.
I don't know if a pakgen is needed, and if it is, I don't know how long it will take to complete since my lexing and yaccing skills rate about 0 on the 1 to 10 scale. I was planning on a very simple script language.

Ionic Wind Support Team

I will look at the list classes.  I did plan on my own, only because I like the old FOR EACH syntax.  But it is not too important.
Ionic Wind Support Team

Zen

All the ones i am doing are on the very first post of this thread. Some of mine are proving to be quite difficult but its helping me learn. Also most of parkers classes are API based whereas some of mine are converting other code.

But its all good fun anyway. Hopefully will have my next class in the pak soon. Just been a little buys.

Lewis

Rock Ridge Farm (Larry)

Can you provide example code on how to use these?

Zen

Which ones? I will adding a small basic example with all my classes to start with. Then after the whole CCL library is finished i suppose me and parker are going to build some kind of app that makes use of every app. It will be a bit crazy but why not.

As far as i know the only class with an example at this moment in time is my Raw class.

Lewis

Parker

I've got a for-each loop :)
for (p = ListGetFirst(l); p <> null; p = ListGetNext(p))
{
    item = ListGetData(p);
    ...
}


You can use the class to, I just am used to those functions from IBasic.

It's not exactly for-each, but it works and gives you more control for example if you wanted to delete a node.

After thinking about it, it seems like that might be possible with BASIC too
FOR p = ListGetFirst(l) TO null STEP ListGetNext(p)

Feel free to write your own, or use mine, they're compatible with IB's I think, if not it just requires a change in how the members of the listnode structure are ordered.

Zen

There will be a CCL update after the weekend. I have almost finished fixing all the pieces togother for mine and parkers classes. There is a new class layout now which makes it easier for me and Parker to compile and easier to distibute. There is also a base common class for all the classes now with the following functions...


class CCL {

/* Constructor & Destructor */

declare CCL();
declare _CCL();

/* Static Methods */

declare GetErrorType(),int;
declare GetLastError(),string;

declare GetVersion(),int;

/* Overidable Methods */

declare virtual OnError(int type,string data);

}


This should make error reporting in the classes a lot easier (Aslong as me and Parker remember to code the errors in ;)) So whenever you have an error, all you need to do is call GetErrorType and / or GetLastError to find out whats going wrong. There is also an overidable error for you if you wish to use it which will perform a custom action whenever an error occurs. So if you wanted to make a message box popup on all errors then you only have to do it once instead of doing it every time with GetLastError.

Please bear in mind thought that currently not all classes support this new feature but it will be implemented in all classes over time.

Lewis

Zen

January 21, 2006, 06:38:29 PM #85 Last Edit: January 22, 2006, 10:18:20 AM by Lewis
Ok here we go. The next version of CCL.

The following classes are in the package...

Lists
Queues
Raw
Stack
Command Line
Registry
Dictionary

There are also some utility functions for threading, GetAuroraDir and AllreadyRunning to detect if a program is already running.

Examples will be coming soon along with docs but we still have a lot more work to do. There are a few choices of how you can use these classes and functions. If you prefer the C/C++ way you can include each class on its own. e.g. #include "classes\dictionary.inc" etc. The other choice is to use #include "ccl.inc" which will include all classes and functions in one simple statement. There is a class for linked lists aswell as just the functions for linked lists. either classes\lists.inc or just lists.inc.

This will be the last update for a while untill we have some more classes ready (unless there are any bugs found ;))

Have fun :D
Lewis

EDIT: Download removed. See latest post for updates.

Parker

Already found a bug ;)

It's an include file bug. A couple of includes used duplicate inclusion guard symbols, so only one file would be included. Lewis is fixing it and a new upload should come very soon.

Also, documentation is coming... I'll be starting soon and hopefully it will be better looking than the plain black and white docs we had with IB. I just prefer it that way, but it won't be filled with images and impossible to read, just a bit better looking.

Zen

Fixed, Updated the file in the post above.

Lewis

Zen

Yes for the docs me an Parker are planning on some kind of e-book software (custom made) which will have the docs in for the common classes, they will also be dynamicly updated when changes are made. It will also feature a Wikki type feature for the users to add comments and tips 'n' tricks.

Lewis

LarryMc

Lewis

QuoteIt will also feature a Wikki type feature for the users to add comments and tips 'n' tricks
.

That was one of the items on my wish list! ;D
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Zen

Well it seemed like a good idea because sometimes people have difficulty reading docs and understanding them, so i thought if you can post comments and your own tips 'n' tricks then it would help others out.

Lewis

Zen

January 22, 2006, 10:17:29 AM #91 Last Edit: January 30, 2006, 06:00:09 AM by Lewis
Another little bug fix. The MySQL class definition was included in the distribution, causing errors if you included the CCL library via CCL.inc. Worked fine just including the classes on there own.

EDIT: download removed. see here for the latest update

Lewis

Zen

Would there be any interest in a sort of wrapper class for microsofts cryptography API. It would take some time as there is a lot of functions and structures etc. But if there is any interest in it i would be happy to code it?

Let me know what you think.

Lewis

Parker

I think we should wait even if there is some interest, since there are already many other classes needing to be written first. Like HTTP ;)

Zen

Im currently working on the HTTP class now. Im having a problem though with the connect API function. It takes a pointer to a null terminated string of a website address. ie. www.google.com. However it is returning false and telling me that the URL is invalid. In microsofts example the use L"www.microsoft.com" what is the L all about???

Lewis

Parker

The L means that it's a unicode string. If there's an ASCII version of the function use it, otherwise you'll have to use MultiByteToWideChar or Paul's a2w when he makes it.

Zen

It doesnt say at the bottom of the SDK like most functions that there is an ASCII version. Ill give this MultiByteToWideChar a blast then

Lewis

Zen

Due to some functions that use Unicode. There will be some Unicode functions added to the CCL library. Parker is currently writing them now so they will be available in the next update.

Lewis

Parker

Done, I know Paul will have some too, so mine are called ToUnicode and FromUnicode. Just so you know, it uses UTF-16 which is the character set used by NT based kernels string processing. There are different versions of unicode though.

There's also a unicode string length function ( _unistrlen ) just in case anyone needs it.

Zen

Ok there seems to some strange problem with the unicode stuff. If i put the unicode functions into the CCL library i found the problem didnt work. After some playing around it seemed that the functions were not being checked when compiing. If i made the declare extern statement but didnt define the library to get the functions from the compiler didnt declare an unresolved extern. However if i prefix the commands with "my" i seem to get the unresolved extern. Maybe Paul has reserved the function names that we are trying to use. If not then there is a problem.

Lewis