April 29, 2024, 10:44:03 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Aurora Common Classes

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

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Parker

There are certain times when using a class would be abusing OOP, and I think that's when. You don't want to do this
Misc m;
x = m.GetAuroraDir();


It would be best I think, to just implement them as functions. Although if another class ends up needing them I'll make a wrapper. But for now, I think those functions will do.

A CommandLine class might not be all that bad of an idea though, I'll see how it goes when the functions are done.

Zen

I was also thinking about making a Registry class too.

Lewis

Zen

January 12, 2006, 03:33:13 PM #27 Last Edit: January 12, 2006, 07:05:46 PM by Lewis
Ok here we go. Apart from one more little update i need to make which will prevent you making GUI apps its all prety much done for the Raw internet class. Attached is the latest update with 2 examples (Server & Client), both are console apps to keep things simple and see how it works

Please let me know of any feature requests or wishlists and i will try my best to do it.

Lewis

EDIT: File removed, check latest post for updates.

Zen

Oh yes just another bug i seemed to of missed off, When either sending or recieving data (havnt figured out which one), two bytes are being added to the data, i believe this is because the winsock functions are using pointers thus adding the 2 bytes. I will fix this for the next update.

Lewis

Parker

Registry's not a bad idea, I'll put it on my todo list unless someone else wants to take on the challenge.

Zen

I dont mind doing it either. im just deciding which class to do next. I will do whatever is the most popular. At the moment i think most people are just learning the language rather than diving in at the deep end like me. I am learning while i am making this project. Still need to learn a bit about the difference between pointers in Aurora and IBasic as i keep getting a lot of compile errors.

Lewis

Zen

January 12, 2006, 07:00:05 PM #31 Last Edit: January 13, 2006, 02:48:58 PM by Lewis
Ok here is another update.

We now have the following classes...

Raw Internet Class
Linked List Class
Stacks Class
Queue's Class

The last 3 were kindly donated by parker, my partner in crime ;)

Hopefully there will be some more interest as we build more and more classes and get some more working example code.

Lewis

...Now where did i put that drawing board ;)

EDIT: File removed, see my latest post for updated version

Parker

Oops, I thought I had dictionary in that archive. It'll be there in a later update. Give me a minute and I'll write a really simple installer that just copies the files to the Aurora directories.

Parker

Here's the limited installer I came up with for now. It doesn't copy the includes though, since they're in their own folder :( I'll fix it tomorrow, but I have to go now.

#use "advapi32.lib"
declare import, RegOpenKeyEx alias RegOpenKeyExA(
unsigned int hKey,
string lpSubKey,
unsigned int ulOptions,
unsigned int samDesired,
pointer phkResult
),unsigned int;

declare import, RegCloseKey(
unsigned int hKey
),unsigned int;

declare import, RegQueryValueEx alias RegQueryValueExA(
  unsigned int hKey,
  string lpValueName,
  unsigned int *lpReserved,
  unsigned int *lpType,
  byte *lpData,
  unsigned int *lpcbData
);

#define HKEY_CURRENT_USER 0x80000001
#define KEY_READ 0x20019
#define KEY_QUERY_VALUE 0x0001
#define REG_SZ 1
#define RRF_RT_REG_SZ 0x00000002
#define ERROR_SUCCESS 0

global sub GetAuroraDir(string directory)
{
// The key we need is under HKCU\Software\IonicWind\Aurora\PATHS -- it is called BIN.
unsigned int key, size=255, type;
string value;
RegOpenKeyEx(
HKEY_CURRENT_USER,
"Software\\IonicWind\\Aurora\\PATHS",
0,
KEY_READ | KEY_QUERY_VALUE,
key);

if( key = 0 )
{
directory = "";
return;
}

if( RegQueryValueEx(key, "BIN", NULL, type, value, size) <> ERROR_SUCCESS )
{
directory = "";
RegCloseKey(key);
return;
}
if (type <> REG_SZ)
{
directory = "";
RegCloseKey(key);
return;
}

// Remove the 'bin' part.
for (i = len(value); i >= 0; i--)
{
if (value[i] = 92) break;
}
directory = left$(value, i+1); // Leave the \ since that's GetStartPath's behaivor
RegCloseKey(key);
return;
}

global sub main()
{
string source, dest, file;
unsigned int handle, attrib;

source = GetStartPath();
GetAuroraDir(dest);

MessageBox(0, "Existing files will be overwritten.", "Notice");

handle = FindOpen(source+"libs\\*.*");
if (handle = 0) return;
do
{
file = FindNext(handle, attrib);
if (file <> "" and file <> "." and file <> "..")
CopyFile(source+"libs\\"+file, dest+"libs\\"+file, 0);
} until (file = "");
FindClose(handle);

handle = FindOpen(source+"include\\*.*");
if (handle = 0) return;
do
{
file = FindNext(handle, attrib);
if (file <> "" and file <> "." and file <> "..")
CopyFile(source+"include\\"+file, dest+"include\\"+file, 0);
} until (file = "");
FindClose(handle);

handle = FindOpen(source+"examples\\*.*");
if (handle = 0) return;
do
{
file = FindNext(handle, attrib);
if (file <> "" and file <> "." and file <> "..")
CopyFile(source+"examples\\"+file, dest+"examples\\"+file, 0);
} until (file = "");
FindClose(handle);

return;
}

Zen

I tried to make a installer with INNO setup because ive used it before and its really good but i couldnt figure out how to read a registry key and install the package to the path from the registry. Ohh well looks like custom installer is the way to go. Ill do one of the compression classes today. Then i think im going to finish off the native MySQL class.

Lewis

Ionic Wind Support Team

It can be done with Inno but it's not an easy task.  Which is why I asked Fletchie to write PakGen so many years ago.
Ionic Wind Support Team

Zen

I thought there must be a way but i found it a bit hard to track down docs to do it. I used the ISTool program to create my installers.

Lewis

Steven Picard

That is actually a very easy task in Inno now that the Pascal scripting is officially integrated.

Zen

I dont know too much about pascal. I think i wrote a card shuffle routine at uni in pascal and thats it.

Lewis

Steven Picard

I'll try and get the answer for you when I get a chance today.

Zen

oh that would be great. Thanks a lot steven. It would make life easier.

Lewis

Ionic Wind Support Team

I'll have to download the latest version and check it out too. 
Ionic Wind Support Team

Zen

Check out the common classes too ;)

Lewis

Ionic Wind Support Team

Ionic Wind Support Team

Zen

January 13, 2006, 07:56:34 AM #44 Last Edit: January 13, 2006, 07:58:42 AM by Lewis
Currently working on zLib class. At the moment it will need the zLib dll which will be included. Later on i plan to convert the whole source code for zLib. This way when the whole class library is complete it will be totaly self reliant, keeping the amount of extra files needed to be shipped with an app to a minimal. ;)

current class looks like this...

class zLib {

declare OpenArchive();
declare CloseArchive();

declare AddFile();
declare RemoveFile();

declare Compress();
declare Decompress();

declare Inflate();
declare Deflate();

declare GetCRC32();
declare GetAdler32();

}


Obviously the functions will have peramaters (would be clever if it didnt though :D). This is just for people to get an idea of how easy i plan it to be. Hopefull the other compression classes will use the same class definition. Maybe merge them all into one and just add another method to select which compression you want.

Lewis

Parker

I wrote the GetAuroraDir function for a pakgen program that I'll write when a compression class is finished. It's going to be my experiment with flex and bison, I'll have it be a (really) simplistic scripting system that generates Aurora code and builds it.

Zen


Steven Picard

January 13, 2006, 12:42:18 PM #47 Last Edit: January 13, 2006, 12:44:01 PM by stevenp
Here is an example for installing to a previous installation directory.  It should work although I didn't test it (deadline looming at work  ::))  But you should get the idea and it should at least point you in the right direction.


[Files]
Source: "myprogram.exe"; DestDir: "{code:installDirectory}";

[ code]
Function installDirectory(default: string): string;
Begin
Result := RegQueryStringValue(HKCU, 'Software\IonicWind\Aurora\PATHS', 'BIN', '');Boolean
End


(I had to add a space in the section [ code] because the forum kept trying to use it as a formatting tag)

Let me know if you need anymore help with Inno.

Zen

Thanks a lot steven. I will give that a try later on. Having a break again now as the headaches have come back, it seems they let me have yesterday off.

Lewis

Zen

January 13, 2006, 02:47:57 PM #49 Last Edit: January 30, 2006, 06:00:51 AM by Lewis
Ok got it working now. After a little bit of googling and the example code above to head me in the right direction i managed to get Inno Setup working to install the common classes in the Aurora directory.

final pascal script was...

Function installDirectory(default: string): string;

var Path: String;

begin

Path := '';
RegQueryStringValue(HKCU,'Software\IonicWind\Aurora\PATHS','BIN',Path);
Result := Path;

end;


Here is the latest version of the common classes too.

EDIT: download removed. see here[/url for the latest update

Lewis