Question about Requesters

8 posts / 0 new
Last post
OldFart
OldFart's picture
Offline
Last seen: 1 month 3 weeks ago
Joined: 2010-11-30 14:09
Question about Requesters

Hi,

When using a requester that has tag REQ_TimeOutSecs defined (with a value > 0) and subsequently the requester DOES time out, what is then the return value of the method? Do I correctly assume this to be 0? Or?

  1. void VARARGS68K MessageBox(struct ExecParam *xn, ...)
  2. {
  3. INFO_ENTER
  4.  
  5. va_list ap;
  6. va_startlinear(ap, xn);
  7. IExec->RawDoFmt((__RD)->rd_FormatText, va_getlinearva(ap, void*), NULL, (__RD)->rd_BodyText);
  8. va_end(ap);
  9.  
  10. struct TagItem ReqTags[] = {{REQ_Type , (__RD)->rd_Type}
  11. ,{REQ_TitleText , (uint32)(__RD)->rd_TitleText}
  12. ,{REQ_GadgetText , ( (__RD)->rd_GadgetText) ? ((uint32)(__RD)->rd_GadgetText)
  13. : ((uint32) INFO_GADGETTEXT)}
  14. ,{REQ_BodyText , (uint32)(__RD)->rd_BodyText}
  15. ,{REQ_TimeOutSecs, (uint32)(__RD)->rd_TimeOut}
  16. ,{REQ_Image , (uint32)(__RD)->rd_Image}
  17. ,{TAG_END , (uint32)0}
  18. };
  19.  
  20. struct orRequest ReqMsg = {RM_OPENREQ, ReqTags, (__RD)->rd_Window, (__RD)->rd_Screen};
  21.  
  22. if (rd->rd_WinObj != NULL)
  23. {
  24. IIntuition->SetAttrs(*(__RD)->rd_WinObj, WA_BusyPointer, TRUE, TAG_END);
  25. (__RD)->rd_Response = IIntuition->IDoMethodA((__RD)->rd_ReqObj, (APTR)&ReqMsg);
  26. IIntuition->SetAttrs(*(__RD)->rd_WinObj, WA_BusyPointer, FALSE, TAG_END);
  27. }
  28. else
  29. {
  30. (__RD)->rd_Response = IIntuition->IDoMethodA((__RD)->rd_ReqObj, (APTR)&ReqMsg);
  31. }
  32.  
  33. INFO_VACATE
  34. }

And now that I'm at it, how would tag 'Req_VarArgs' fit in here? Would this cut that cake?

  1. void VARARGS68K MessageBox(struct ExecParam *xn, ...)
  2. {
  3. INFO_ENTER
  4.  
  5. va_list ap;
  6. va_startlinear(ap, xn);
  7. va_end(ap);
  8.  
  9. struct TagItem ReqTags[] = {{REQ_Type , (__RD)->rd_Type}
  10. ,{REQ_TitleText , (uint32)(__RD)->rd_TitleText}
  11. ,{REQ_GadgetText , ( (__RD)->rd_GadgetText) ? ((uint32)(__RD)->rd_GadgetText)
  12. : ((uint32) INFO_GADGETTEXT)}
  13. ,{REQ_VarArgs , (uint32)va_getlinearva(ap, void*)}
  14. ,{REQ_BodyText , (uint32)(__RD)->rd_FormatText}
  15. ,{REQ_TimeOutSecs, (uint32)(__RD)->rd_TimeOut}
  16. ,{REQ_Image , (uint32)(__RD)->rd_Image}
  17. ,{TAG_END , (uint32)0}
  18. };
  19.  
  20. struct orRequest ReqMsg = {RM_OPENREQ, ReqTags, (__RD)->rd_Window, (__RD)->rd_Screen};
  21.  
  22. if (rd->rd_WinObj != NULL)
  23. {
  24. IIntuition->SetAttrs(*(__RD)->rd_WinObj, WA_BusyPointer, TRUE, TAG_END);
  25. (__RD)->rd_Response = IIntuition->IDoMethodA((__RD)->rd_ReqObj, (APTR)&ReqMsg);
  26. IIntuition->SetAttrs(*(__RD)->rd_WinObj, WA_BusyPointer, FALSE, TAG_END);
  27. }
  28. else
  29. {
  30. (__RD)->rd_Response = IIntuition->IDoMethodA((__RD)->rd_ReqObj, (APTR)&ReqMsg);
  31. }
  32.  
  33. INFO_VACATE
  34. }

And then, whilst going through 'classes/requester.h', I encountered that very sexy sounding tag 'REQ_StayOnTop'. I'll try and see how that one can be fitted in.

OldFart

msteed
msteed's picture
Offline
Last seen: 2 months 1 week ago
Joined: 2022-01-18 08:34
Re: Question about Requesters

I can't help with REQ_VarArgs, as I've never played with that. But for the timeout, the autodoc says:

For all [requester] types, returns -1 when a timeout occured or when an IDCMP event specified with REQ_IDCMP_Ptr occurred.

OldFart
OldFart's picture
Offline
Last seen: 1 month 3 weeks ago
Joined: 2010-11-30 14:09
Re: Question about Requesters

@msteed

I missed that one. Thanks!

OldFart

thomas
thomas's picture
Offline
Last seen: 1 month 3 weeks ago
Joined: 2011-05-16 14:23
Re: Question about Requesters

I am quite sure that every reference to ap is illegal after va_end(ap) and also the result of va_getlinearva becomes invalid after va_end. So you have to move va_end to the end of your function, at least after DoMethod.

OldFart
OldFart's picture
Offline
Last seen: 1 month 3 weeks ago
Joined: 2010-11-30 14:09
Re: Question about Requesters

@thomas

I am quite sure that every reference to ap is illegal after va_end(ap) and also the result of va_getlinearva becomes invalid after va_end.

Sounds (and seems) logical. Thanks.

OldFart

jabirulo
jabirulo's picture
Offline
Last seen: 1 month 3 weeks ago
Joined: 2013-05-30 00:53
Re: Question about Requesters

@OldFart

for the REQ_VarArgs, you can take a look in playcdda_gui.c (os4depot)
http://www.os4depot.net/share/audio/play/playcdda_gui.lha

or this one:

  1. VARARGS68K VOID SV_Message(CONST_STRPTR text, ...)
  2. {
  3. ULONG idcmp = 0L;
  4. struct EasyStruct estr;
  5. va_list args;
  6. ULONG *vargs = NULL;
  7.  
  8. #if defined(__amigaos4__)
  9. va_startlinear(args,text);
  10. vargs = va_getlinearva(args,ULONG *);
  11. #else
  12. va_start(args,text);
  13. vargs = args;
  14. #endif
  15.  
  16. if(RequesterBase)
  17. {
  18. struct Screen *scr = LockPubScreen(NULL);
  19. Object *req = NewObject(RequesterClass, NULL,
  20. REQ_Image, REQIMAGE_WARNING,
  21. REQ_TitleText, GETMSG(MSG_AKDT_MESSAGE),
  22. REQ_BodyText, text,
  23. REQ_VarArgs, vargs,
  24. REQ_GadgetText, GETMSG(MSG_INFOWIN_OK),
  25. TAG_DONE);
  26. if(req)
  27. {
  28. //SETWINDOWBUSY(TRUE);
  29. IDoMethod(req, RM_OPENREQ, NULL, NULL, scr);
  30. //SETWINDOWBUSY(FALSE);
  31. DisposeObject(req);
  32. }
  33. UnlockPubScreen(NULL, scr);
  34. va_end(args);
  35. return;
  36. }
  37.  
  38. if(!IntuitionBase) IntuitionBase = OpenLibrary("intuition.library", 37);
  39. if(!IntuitionBase) return;
  40.  
  41. estr.es_StructSize = sizeof(struct EasyStruct);
  42. estr.es_Flags = 0L;
  43. estr.es_Title = GETMSG(MSG_AKDT_MESSAGE);
  44. estr.es_TextFormat = text;
  45. estr.es_GadgetFormat = GETMSG(MSG_OK);
  46.  
  47. EasyRequestArgs(NULL, &estr, &idcmp, vargs);
  48.  
  49. va_end(args);
  50. }

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

OldFart
OldFart's picture
Offline
Last seen: 1 month 3 weeks ago
Joined: 2010-11-30 14:09
Re: Question about Requesters

@Jabirulo

Thanks!

OldFart

hypex
hypex's picture
Offline
Last seen: 2 months 6 days ago
Joined: 2011-09-09 16:20
Re: Question about Requesters

@OldFart

I encountered that very sexy sounding tag

LOL. Also, if you are also to target DOS 51.12+, then you can use TimedDosRequester(). Which provides a similar but simpler function to display a similar requester.

Log in or register to post comments