home *** CD-ROM | disk | FTP | other *** search
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <intuition/intuitionbase.h>
- #include <proto/exec.h>
- #include <proto/dos.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
- #include <proto/tool.h>
- #include <string.h>
- #include <stdlib.h>
- #include <stdio.h>
-
- VOID main();
-
- struct Library *ToolBase;
- struct IntuitionBase *IntuitionBase;
- struct GfxBase *GfxBase;
-
- char ja[]="JA !";
- char nein[]="NE !!";
- char body1[]="Sind Sie fertig ?";
- char body2[]="Wirklich ?";
- char for_check[]="1+2+3+4-(a-34+5)";
- char string[50];
- char string1[50];
- char Zahl_string[]="-1.3467";
-
- SHORT paare3[]=
- {
- 0,0,0,9,33,9,33,0,0,0
- };
-
- struct Border Rand1 =
- {
- -1,-1,3,2,JAM2,5,paare3,0
- };
-
- struct IntuiText Texte=
- {
- 3,2,JAM2,0,0,0," OK ",0
- };
-
- /* Definitionen für Gadgets */
-
- struct Gadget G=
- {
- NULL ,100,20,32,8,GADGHCOMP,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,(APTR)&Rand1,0,&Texte,NULL,NULL,4,0
- };
-
-
-
- struct NewWindow Fenster=
- {
- 10,10,520,130,0,1,CLOSEWINDOW|GADGETDOWN,WINDOWCLOSE,&G,0,"TestWindow",
- 0,0,0,0,0,0,WBENCHSCREEN
- };
-
-
- VOID main()
- {
- struct Window *Window;
- struct RastPort *RastPort;
- struct info msgInfo;
- struct Block *Start;
- APTR Konstanten;
-
-
- long a,ENDE=1;
- DOUBLE Zahl=1.2345677;
- DOUBLE Zahl1=10346.2457;
-
- IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0);
- if(!IntuitionBase)return;
- GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0);
- if(!GfxBase)
- {
- CloseLibrary((struct Library *)IntuitionBase);
- return;
- }
-
-
- ToolBase=OpenLibrary("tool.library",0);
- if(!ToolBase)
- {
- CloseLibrary((struct Library *)IntuitionBase);
- CloseLibrary((struct Library *)GfxBase);
- return;
- }
-
- Window=OpenWindow(&Fenster);
- if(!Window)goto ende;
- printf("Fenster offen\n");
- Delay(20);
- RastPort=Window->RPort;
-
- a=request(ja,nein,body1);
- printf("\n\nIhre Antwort : %ld\n",a);
-
- /* Fast die gleiche Funktion, nur kann hier noch das Fenster angegeben werden */
- a=NewRequest(Window,ja,nein,body2);
- printf("Ihre Antwort : %ld\n",a);
-
- left(string,body1,3);
- printf(" >%s< -> >%s<\n",body1,string);
-
- right(string,body1,4);
- printf(" >%s< -> >%s<\n",body1,string);
-
- mid(string,body1,5,4);
- printf(" >%s< -> >%s<\n",body1,string);
-
- UmwFtoS(string ,&Zahl ,4);
- UmwFtoS(string1,&Zahl1,3);
- printf("Aus >%6.3lf< wird >%s<\n",Zahl ,string );
- printf("Aus >%6.3lf< wird >%s<\n",Zahl1,string1);
-
- UmwStoF(&Zahl,Zahl_string);
- printf("Aus >%s< wird >%6.3lf<\n",Zahl_string,Zahl);
-
- Fak(&Zahl,5);
- printf("Fakultät von 5 ist : %6.3lf\n",Zahl);
- NuK(&Zahl,49,6);
- printf("49 über 6 ist : %6.3lf\n",Zahl);
-
- a=check('+','-',0,strlen(for_check),for_check);
- printf("Erstes + oder - in >%s< bei : %ld\n",for_check,a);
-
- a=checkback('-','-',0,strlen(for_check),for_check);
- printf("Letztes - in >%s< bei : %ld\n",for_check,a);
-
- a=AnzahlKlammern(for_check);
- printf("Unpaarige Klammern: %ld\n",a);
-
- /* Ein bischen malen... */
- for(a=10;a<=500;a+=50)
- {
- Box(RastPort,a,40,a+30,70);
- }
-
- /* Für Flood vorbereiten */
- if(PrepareTmpRas(RastPort))
- {
- for(a=10;a<=500;a+=50)
- {
- Flood(RastPort,1,a+1,41);
- }
- Delay(50);
- }
- /* Kann sein, daß der Blitter hier noch am arbeiten ist, daher lösche ich */
- /* TmpRas erst später */
-
- Print(RastPort,"Dies ist ein Text",2,70,20);
- Center(Window,"Dies ist ein Text",1,30);
-
- for(a=0;a<=3;a++)
- {
- Gadget_Off(&G,Window);
- printf("aus\n");
- Delay(30);
- Gadget_On(&G,Window);
- printf("ein\n");
- Delay(30);
- }
- /* Hier sollte der Blitter eigentlich fertig sein */
- ClearTmpRas(RastPort);
- SetAPen(RastPort,0);
- RectFill(RastPort,5,50,500,110);
- SetAPen(RastPort,2);
-
-
- if(a=PrepareArea(RastPort,100))
- {
- AreaMove(RastPort,110,30);
- AreaDraw(RastPort,130,100);
- AreaDraw(RastPort,105,50);
- AreaEnd(RastPort);
- Delay(50);
- ClearArea(RastPort);
- }
-
- /* Ein wenig rechnen */
- strcpy(string,"sin(x)+a");
- Konstanten=Init_Konst();
- Zahl=1.0;
- Set_Konst_P(Konstanten,1,&Zahl); /* a auf 1.0 setzten */
-
- Start=Init_Mem(string);
- a=Init_Block(Start);
- a|=PreCalc(Start,Konstanten);
- printf("Es sind folgende Fehler aufgetreten : %ld\n",a);
-
- for(Zahl=0.0;Zahl<=3.141;Zahl+=.1)
- {
- Calc_P(&Zahl1,Start,&Zahl);
- printf(">%s< x=%6.3lf %6.3lf\n",string,Zahl,Zahl1);
- }
-
- Free_Block(Start);
- Free_Konst(Konstanten);
-
- strcpy(string,"sin(x)+cos(x)");
- Zahl=.345763;
-
- /* Alternative für wenige Rechnungen */
- berechnen(&Zahl1,string,&Zahl,NULL,&a);
- printf("Wert : %6.3lf Fehler %ld\n",Zahl1,a);
-
-
- /* Auf Ende warten */
- while(ENDE)
- {
- Wait(1L<<Window->UserPort->mp_SigBit);
- /* Arbeitet ab, bis keine Events mehr */
- while(EventAbfrage(Window,&msgInfo))
- {
- /* Verzweigt entsprechend der Events */
- switch(msgInfo.NachrichtenArt)
- {
- case CLOSEWINDOW:ENDE=0;
- break;
- case GADGETDOWN:printf("Gadgetdown\n");
- }
- }
- }
-
- CloseWindow(Window);
- ende:
- CloseLibrary(ToolBase);
- CloseLibrary((struct Library *)GfxBase);
- CloseLibrary((struct Library *)IntuitionBase);
- }
-
-