home *** CD-ROM | disk | FTP | other *** search
- /*
- * $
- * $ FILE : requester.c
- * $ VERSION : 1
- * $ REVISION : 2
- * $ DATE : 08-Dec-93 19:19
- * $
- * $ Author : mvk
- * $
- **
- ** This example shows how to use the egsrequest.library.
- ** It is an example for non modal requester.
- ** You can request a lot of messages without waiting for
- ** response from the user.
- ** For example the Filerequester: The user make some
- ** mistakes (select a File as a Device) then you can give
- ** him a requester.
- **
- ** (c) by VIONA-Development 1992/94
- **
- */
-
-
- /*
- ** Init-Routines
- */
-
- #include "global.h"
-
- /*
- **
- */
-
- ER_FileRequestPtr freq;
- ER_SimpleReqPtr sreq,sreq1,sreq2,sreq3;
- EI_EIntuiMsgPtr msg;
- ER_ReqContextPtr mycon;
- ER_RequestPtr req;
-
- struct MsgPort *port;
-
-
- void myError(char *string,int ende)
- {
-
- if ( string != NULL)
- printf("%s\n",string);
-
- CloseLibraries(OpenStruct);
-
- if (ende)
- exit(0);
-
- }
-
- /*
- **
- ** Open the Libraries
- **
- */
-
- BOOL InitLibraries(struct OpenStructTyp *OS)
- {
- struct OpenStructTyp *p = &OS[0];
-
- while (p->Var != NULL)
- {
- if ((*(p->Var) = (ULONG)OpenLibrary(p->Name,p->Version)) == NULL)
- {
- printf(" Can't open %s version %d",p->Name, p->Version);
- return FALSE;
- }
- else
- { p ++; }
- }
- return TRUE;
- }
- /**/
-
- /*
- **
- ** Close Libs
- **
- */
-
- void CloseLibraries(struct OpenStructTyp *OS)
- {
- struct OpenStructTyp *p = &OS[0];
-
- while (p->Name != NULL)
- {
- CloseLibrary((void *)(*(p->Var)));
- *(p->Var) = NULL;
- p++;
- }
- }
-
-
- main()
- {
-
- if ( InitLibraries(OpenStruct) == FALSE)
- myError("Can't OpenLibrary",10);
-
- port = CreatePort(NULL,0);
-
- if ( port == NULL )
- myError("Can't create port",10);
-
- mycon = ER_CreateReqContext();
-
- if (mycon != NULL)
- {
- /*
- ** Create the context for all
- */
-
- freq=ER_CreateFileReq(mycon);
- sreq=ER_CreateSimpleReq(mycon,
- " ! ERROR ! | You select a filename | as a device !",
- " YES | MAY BE | NO ");
-
- sreq1=ER_CreateSimpleReq(mycon,
- " ! ERROR ! | The selected path | doesn't exists !",
- " YES | MAY BE | NO ");
-
- sreq2=ER_CreateSimpleReq(mycon,
- " ! ERROR ! | You select a wrong | devicename !",
- " YES | MAY BE | NO ");
-
- sreq3=ER_CreateSimpleReq(mycon,
- " This is a demo | for non modal | requesters !",
- " YES ");
-
- /*
- ** Init Port in requester struct for use
- ** non modal requesters.
- **
- ** Without a port the the OpenRequest will create
- ** a own port. So that any requester have an own
- ** MsgPort (modal).
- **
- **
- */
-
- freq->Req.Port=port;
- sreq->Req.Port=port;
- sreq1->Req.Port=port;
- sreq2->Req.Port=port;
- sreq3->Req.Port=port;
-
- if (freq != NULL && sreq != NULL)
- if ( (sreq1 != NULL) && (sreq2 != NULL) && (sreq3 != NULL) )
- {
-
- freq->Req.Title="Titel1";
- sreq->Req.Title="Titel2";
- sreq1->Req.Title="Titel3";
- sreq2->Req.Title="Titel4";
- sreq3->Req.Title="Titel5";
-
-
- if ( ER_OpenRequest((ER_RequestPtr)freq,NULL) &&
- ER_OpenRequest((ER_RequestPtr)sreq,NULL) && ER_OpenRequest((ER_RequestPtr)sreq1,NULL) &&
- ER_OpenRequest((ER_RequestPtr)sreq1,NULL) &&
- ER_OpenRequest((ER_RequestPtr)sreq2,NULL) &&
- ER_OpenRequest((ER_RequestPtr)sreq3,NULL)
- ){
-
- while(freq->Req.RWindow)
- {
- WaitPort(port);
-
- msg=(EI_EIntuiMsgPtr)GetMsg((struct MsgPort *)port);
-
- /*
- ** Find the Requester for the msg
- **
- ** if req == NULL the msg
- ** is not from a EGS Requester
- **
- */
-
- if (msg != NULL)
- req = ER_FindRequest(mycon,msg);
-
- if (req != NULL)
- {
- /*
- ** Handle the msg !
- ** For example close Requester
- */
-
- ER_IterateRequest(req, msg);
-
- // printf("Selected gadget%d\n",sreq->Selected);
-
- }
-
- ReplyMsg((struct Message *)msg);
-
- } // while
-
- printf("Name = %s \n\n",freq->Name);
-
- } // if
- }
- }
-
- if( mycon != NULL )
- ER_DeleteReqContext(mycon);
-
- myError(NULL,10);
-
- }/* END */
-
-
-