/*
**  RequestersDemo.rexx
**
*/

OPTIONS RESULTS
EOL = '0A'x

customreq = "Rexx:GTRF/Example.gtrf"

/*------ Add 'rexxext.library' to the REXX Library List -------*/
if (show('L','rexxext.library') == '0') THEN DO
    if (Exists('libs:rexxext.library') == '0') THEN DO
        say 'ERR: rexxext.library not Found'
        EXIT
    END
    ELSE CALL ADDLIB("rexxext.library",-5,-30,0)
END

info = "This Rexx Program demonstrates rexxext.library Request Functions"
call reInfo(,info)

/*-------- Prepare Labels for Cycle Requester -------*/
flist = '"reReqChoice() (2)" "reReqChoice() (3)" reReqStr() reReqInt()'
flist = flist 'reReqFile() "reReqFile() (.info)" "reReqFile() (Patt)" reReqFiles() reReqDrawer() reRequest()'
reqrez = ''


DO FOREVER
    type = reReqCycle(,'Select Function You would like to test',flist)
    if (type == '') THEN BREAK
    select
        when type = 0  then call TestChoice2
        when type = 1  then call TestChoice3
        when type = 2  then call TestStr
        when type = 3  then call TestInt
        when type = 4  then call TestFile
        when type = 5  then call TestFileI
        when type = 6  then call TestFileP
        when type = 7  then call TestFiles
        when type = 8  then call TestDrawer
        otherwise           call TestCustom
    end
    if (reqrez == '') THEN say 'Requester Canceled'
    else DO
        say "Result is :"
        say  reqrez
    END
END

EXIT

TestChoice2:
    reqrez = reReqChoice(,'This is Choise 2 Demo')
    return

TestChoice3:
    reqrez = reReqChoice(,'This is Choise 3 Demo',,,'Ok 2')
    return

TestStr:
    reqrez = reReqStr(,'This is String Req Demo','Some Def. Text')
    return

TestInt:
    ttl = 'This is Integer Req Demo'||EOL||'(Min = -10000 ... Max = 10000)'
    reqrez = reReqInt(,ttl,0,-10000,10000)
    return

TestFile:
    reqrez = reReqFile(,'File Req Demo','Sys:')
    return

TestFileI:
    reqrez = reReqFile(,'File Req (Show .info)','Sys:',,I)
    return

TestFileP:
    reqrez = reReqFile(,'File Req (Pattern)','Sys:','#?.info',I)
    return

TestFiles:
    reqrez = reReqFiles(,'Multi Sel. File Req','Sys:')
    return

TestDrawer:
    reqrez = reReqDrawer(,'Drawer Req Demo','Sys:')
    return

TestCustom:
    def = 'Def Text'                      /* Text for string gadget */
    def = def || EOL || '10 -100 100'     /* Value and limits for int. */
    def = def || EOL || '"Lab 0" "Lab 1"' /* Labels for Cycle Gadget */
    def = def || EOL || '1'               /* Ch. Box Checked */
    def = def || EOL                      /* No file Name or path */
    def = def || EOL || 'sys:'            /* Default drawer 'sys:' */
    reqrez = reRequest(,'Custom Requester Test',customreq,def)
    return
