Home  /  Autodocs  /  requester.class

NAME

RM_OPENREQ
Open a requester.

SYNOPSIS

ULONG button_num = DoMethodA(APTR obj, struct orRequest *msg);

FUNCTION

Opens a requester and returns the number of the button the user selected.

INPUTS

obj
requester object pointer

msg
pointer to fully initialized struct orRequest (see <classes/requester.h>)

RESULT

For REQTYPE_INFO, returns the number of the button the user did select. The buttons are numbered 1, 2, 3, ..., 0. A requester with a single button always returns 0.

For REQTYPE_INTEGER, returns either TRUE or FALSE (= Cancel).

For REQTYPE_STRING, returns FALSE if the string was empty and empty strings were not allowed, otherwise returns TRUE.

For all types, returns 0 when opening the requester failed.

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

EXAMPLE

struct orRequest reqmsg;
struct TagItem tags[10];
char buffer[100] = "Default string";

reqmsg.MethodID = RM_OPENREQ;
reqmsg.or_Attrs = tags;
reqmsg.or_Window = NULL;
reqmsg.or_Screen = myScreenPtr;
tags[0].ti_Tag = REQ_Type;
tags[0].ti_Data = REQTYPE_STRING;
tags[1].ti_Tag = REQ_TitleText;
tags[1].ti_Data = (Tag)"Requesting a string";
tags[2].ti_Tag = REQ_BodyText;
tags[2].ti_Data = (Tag)"Please enter a string";
tags[3].ti_Tag = REQ_GadgetText;
tags[3].ti_Data = (Tag)"_Ok|_Cancel";
tags[4].ti_Tag = REQS_Buffer;
tags[4].ti_Data = (Tag)buffer;
tags[5].ti_Tag = REQS_MaxChars;
tags[5].ti_Data = sizeof(buffer) - 1;
tags[6].ti_Tag = REQS_ShowDefault;
tags[6].ti_Data = TRUE;
tags[7].ti_Tag = REQS_AllowEmpty;
tags[7].ti_Data = FALSE;
tags[8].ti_Tag = REQS_Invisible;
tags[8].ti_Data = FALSE;
tags[9].ti_Tag = TAG_END;
tags[9].ti_Data = 0;

ULONG button_num = DoMethodA(reqobj, (Msg)&reqmsg);
if (button_num == 0)
{
// Cancel button or failed to open.
}

// Buffer contains result string which is the default when
// the user did cancel the requester or it did not open.