Welcome, Guest. Please login or register.

Author Topic: How to program Intuition Example in Storm C.  (Read 2959 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline jonssonjTopic starter

  • Sr. Member
  • ****
  • Join Date: Oct 2003
  • Posts: 254
    • Show only replies by jonssonj
How to program Intuition Example in Storm C.
« on: October 24, 2003, 12:34:45 PM »
Hello!

Is there anyone that have an simple example code of opening and closing a window in amiga os, that are made in Storm C 4?

Very thankful for any example.

Regards from jonssonj
 

Offline Thomas

Re: How to program Intuition Example in Storm C.
« Reply #1 on: October 24, 2003, 01:00:29 PM »

Well, StormC is like any other C, so every example should work. I don't have my Storm C installation here at work, so I cannot verify now if there are some specialties to attend.

Here is an example that works great with Dice C and VBCC. From my experience there should be no difficulty with Storm C.


#include
#include
#include

int main (int argc,char **argv)
{
BOOL cont;
struct Window *win;
struct RastPort *rp;
struct MsgPort *port;
struct IntuiMessage *mess;

if (win = OpenWindowTags (NULL,
      WA_Left,20,WA_Top,10,
      WA_Width,200,WA_Height,50,
      WA_Title,"My Window",
      WA_Flags,WFLG_CLOSEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_ACTIVATE|WFLG_GIMMEZEROZERO,
      WA_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY,
      TAG_END))
   {
   port = win->UserPort;
   rp = win->RPort;

   SetDrMd (rp,JAM2);
   SetAPen (rp,1);
   SetBPen (rp,2);
   Move (rp,10,20);
   Text (rp,"Close me !",10);

   cont = TRUE;
   while (cont)
      {
      WaitPort (port);
      while (mess = (struct IntuiMessage *) GetMsg (port))
         {
         switch (mess->Class)
            {
         case IDCMP_CLOSEWINDOW:
            cont = FALSE;
            break;
         case IDCMP_VANILLAKEY:
            if (mess->Code == 0x1b) /* Esc */
               cont = FALSE;
            break;
            }
         ReplyMsg ((struct Message *)mess);
         }
      }

   CloseWindow (win);
   }

return (0);
}


Bye,
Thomas

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: How to program Intuition Example in Storm C.
« Reply #2 on: October 24, 2003, 01:26:36 PM »
Quote
#include
#include
#include

...and to make it work on all amiga compilers, use:
#include
#include
#include
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: How to program Intuition Example in Storm C.
« Reply #3 on: October 24, 2003, 01:27:42 PM »
I was just about to say the same thing...
int p; // A
 

Offline jonssonjTopic starter

  • Sr. Member
  • ****
  • Join Date: Oct 2003
  • Posts: 254
    • Show only replies by jonssonj
Re: How to program Intuition Example in Storm C.
« Reply #4 on: October 24, 2003, 01:51:27 PM »
I will try it out when I get home from work. I had an old example that was made for WB1.3, they used the exit() function and Storm C could not find a prototype for exit().

The strange thing was that Storm C could not find a prototype for CloseLibrary either. But I will try your example as soon as I get home...   :-D
 

Offline Thomas

Re: How to program Intuition Example in Storm C.
« Reply #5 on: October 24, 2003, 02:11:13 PM »
Quote

Piru wrote:
...and to make it work on all amiga compilers, use:
#include
#include
#include



Erm, no. Dice C has heavy problems with register calls (proto/xxx includes pragma/xxx). Sometimes it uses A6 as a scratch register after it has loaded the library base into it and other faults. Also it easily runs out of registers.

Bye,
Thomas

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: How to program Intuition Example in Storm C.
« Reply #6 on: October 24, 2003, 02:41:06 PM »
Quote
Erm, no. Dice C has heavy problems with register calls (proto/xxx includes pragma/xxx). Sometimes it uses A6 as a scratch register after it has loaded the library base into it and other faults. Also it easily runs out of registers.

If that is indeed the case, Dice C deserves to die already. There are better working alternatives now.