@cycloid
well i've scoured the "Amiga C Tutorial" website at liquido2.com for an email link but cant find one, so i'll post it here. i got my first amiga window runnig using the source but found some "issues" with the code that needed debugging, here they are:
Thanks for the feedback. Actually my email address (
amiga@ssmnet.net) is found in the
introduction, but I should probably add it somewhere in every tutorial.
>45 struct IntuiText *MyText;
this fills me with dread, surely that should be:
>45 struct IntuiText *MyText = new IntuiText;
but does that mean i have to "free" it when i shutdown?
Good catch. This should fill you with dread and is my bad for not catching it in the first place. You are correct that the memory should be reserved for the IntuiText structure. The Amiga way of doing this is:
struct IntuiText *MyText = (struct IntuiText *)AllocMem( sizeof( struct IntuiText ), 0L );
And yes, if you allocate memory in this way you must free it after you are done using it by adding:
FreeMem( MyText, sizeof( struct IntuiText) );
to the end of that block.
An alternative would be to create a real IntuiText structure instead of a pointer to an IntuiText structure:
struct IntuiText MyText;
MyText.LeftEdge = 10;
MyText.TopEdge = 20;
MyText.IText = "Click the close button to exit!";
MyText.DrawMode = JAM1;
MyText.FrontPen = 1;
MyText.NextText = NULL;
PrintIText( MyWindow->RPort, &MyText, 0, 0 );
This is the change I will make to the tutorial source.
>54 PrintIText( MyWindow->RPort, MyText, 0, 0 );
changing it to this:
>54 PrintIText( MyWindow->RPort, MyText, MyWindow->BorderLeft, MyWindow->BorderTop );
offsets it into the window's window bit. i learnt that by reading intuition.h
Very true, but as mentioned already, adding a WA_GimmeZeroZero tag when defining the window will do the same automagically.
>104 CloseLibrary( (struct Library *)IntuitionBase );
This caused shell lockups and all sorts of memory trouble, it worked cleanly when i made it:
>104 CloseLibrary( IntuitionBase );
The code in the tutorial is correct for ANSI C compilers such as GCC. Strictly speaking, CloseLibrary() expects an argument of type struct Library *. The pointer IntuitionBase is of type struct IntuitionBase * not struct Library * (although the IntuitionBase structure actually begins with a Library structure) and therefore must be cast to a struct Library * when used in CloseLibrary(). Including the protos as mentioned earlier is a good way to catch these type mismatches. By the way, which compiler are you using?
And yes, I forgot the return 0 at the end of main(). ;-)
Thank you for bringing up these errors. I'll correct them and publish the updated tutorials.
Also, you might be able to find some very useful documentation near the bottom of
this page.