                            LISTING 4

     TestSR.c Program for Testing the StringsRequest Function


/***********************************************************
 *                                                         *
 *  TestSR.c -- (C) Copyright 1988, by Randy Finch         *
 *                                                         *
 *  Program to test StringsRequest function                *
 *                                                         *
 *  This program was compiled with Lattice C v4.01         *
 *  and linked with StrReq.o using BLINK                   *
 *                                                         *
 *  Run from CLI                                           *
 *                                                         *
 ***********************************************************/

#include <exec/types.h>
#include <intuition/intuition.h>

extern BOOL StringsRequest();
struct IntuitionBase *IntuitionBase;

struct NewWindow newwin = {
    0,0,640,200,          /* LeftEdge, TopEdge, Width, Height */
    0,1,                        /* DetailPen, BlockPen */
    MENUPICK | CLOSEWINDOW |    /* IDCMPFlags */
    GADGETUP | GADGETDOWN | REQCLEAR,
    WINDOWSIZING | WINDOWDRAG |
    WINDOWCLOSE |
    ACTIVATE | SMART_REFRESH,   /* Flags */
    NULL,                       /* FirstGadget */
    NULL,                       /* CheckMark */
    "Test Window",              /* Title */
    NULL,                       /* Screen */
    NULL,                       /* BitMap */
    20,20,                      /* MinWidth, MinHeight */
    640,200,                    /* MaxWidth, MaxHeight */
    WBENCHSCREEN  };            /* Type */

UBYTE  HText[80];        /* Header Text */
UBYTE  NumEnt;           /* Number of string gadgets */
WORD   BoxWid[10];       /* Array of gadget widths */
UBYTE  titles[10][80];   /* Array of gadget titles (10 strings,
                              80 characters max) */
UBYTE  deftext[10][80];  /* Array of default text for gadgets */
WORD   maxlen[10];       /* Array of maximum default text string
                              lengths (80 max) */
WORD   typedt[10];       /* Array of gadget types
                              (0 - regular, 1 - long integer) */
LONG   temp;             /* Temporary variable */
STRPTR Titles[10];       /* Array of pointers to title strings */
STRPTR Deftext[10];      /* Array of pointers to default
                              text strings */

void main()
{
struct Window *win;
UBYTE i;
BOOL rt;

/*  Get information about requester  */

printf("Header: ");
scanf("%s",HText);
printf("Number of Entries: ");
scanf("%d",&temp);  NumEnt = (UBYTE)temp;
for(i=0; i<NumEnt; ++i) {
  printf("Box width: ");
  scanf("%d",&temp);  BoxWid[i] = (WORD)temp;
  printf("Title: "); scanf("%s",&titles[i][0]);
  printf("Def text: "); scanf("%s",&deftext[i][0]);
  printf("Max len: ");
  scanf("%d",&temp);  maxlen[i] = (WORD)temp;
  printf("Type: ");
  scanf("%d",&temp);  typedt[i] = (WORD)(temp*LONGINT);
}

/*  Assign pointer arrays  */

for(i=0; i<NumEnt; ++i) {
  Titles[i] = &titles[i][0];
  Deftext[i] = &deftext[i][0];
}

/*  Open window  */

IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library",0);
win = (struct Window *) OpenWindow(&newwin);

/*  Call StringsRequest  */

rt = StringsRequest(HText, NumEnt, BoxWid, Titles, Deftext, maxlen, typedt, win);

/*  Close window  */

CloseWindow(win);
CloseLibrary(IntuitionBase);

/*  Print current gadget text  */

for(i=0; i<NumEnt; ++i)
  printf("Deftext[%d]: %s\n", i, Deftext[i]);

}

