SUBROUTINE RadioButton(ANSWER,SUB.DATA,P.NBR,SAVE.PROMPT,SAVE.FN,VALUE)
* Release Information
* MFG - CUST - 6.0
*  - Radio Button driver.
LastUpdated... = "Rev: 10:36 30Jun1994 u2443 38 /users/u2443/BP/RADIO.BUTTON"
***
* Abstract:
*    This program will handle all the processes needed to emulate a
* radio button on a text based screen. Options are taken from the
* OPTION and OPTION.TEXT items of the PMT array.
*
***
* R e v i s i o n   L o g
* Proj Who.. When.... Why................................................
* NONE u2443 06/16/94 Initial coding.
*
***

$INSERT UPCASE.EQUATES

*#* COPY COPY.TOOLS.BP STANDARD.VARIABLES.4
$INCLUDE COPY.TOOLS.BP STANDARD.COMMON.VARIABLES
$INCLUDE COPY.TOOLS.BP STANDARD.COMMON.APP.PROGRAMS
$INCLUDE COPY.TOOLS.BP COM500
$INCLUDE COPY.TOOLS.BP AUX.COMMON.APP.PROGRAMS
$INCLUDE COPY.TOOLS.BP STANDARD.VARIABLES.END
*#*

$INCLUDE FDEF PMT.FDEF
$INCLUDE COPY.TOOLS.BP PROCESSING.CODES

DEBUG
ERROR=0
PROMPT = SAVE.PROMPT
AMC = PROMPT<1,PMT$AMC>
FileNumber = PROMPT<1,PMT$FILE.NUMBER>
Col = PROMPT<1,PMT$COLUMN>
Row = PROMPT<1,PMT$ROW>
BEGIN CASE
   CASE SIPTOP
   CASE SIPEND
   CASE SIPDEL
   CASE AFTER.PROMPT
   CASE BEFORE.PROMPT
      Options = PMT<PMT$OPTION>
      OptionTexts = PMT<PMT$OPTION.TEXT>
      gosub DisplayOptions
      gosub DisplaySelection
      gosub SelectOption
      gosub DisplaySelection
   CASE AFTER.READ
      Options = PMT<PMT$OPTION>
      OptionTexts = PMT<PMT$OPTION.TEXT>
      gosub DisplayOptions
      gosub DisplaySelection
   CASE BEFORE.DISPLAY
END CASE
RETURN


DisplayOptions:
MoreOptions = Options ne ""
iCol = Col                              ;* Make room for SCREEN.IP's work field.
iRow = Row
i = 1
loop while MoreOptions
   remove Option from Options setting MoreOptions
   remove OptionText from OptionTexts setting dummy
   crt @(iCol,iRow):"( ) ":Option:" - ":OptionText:
   iRow += 1
   i += 1
repeat
return


DisplaySelection:
CurrentValue = FILE.ITEM(FileNumber)<AMC>
Options = Options
iCol = Col                              ;* The button column
iRow = Row
locate CurrentValue in Options<1,1> setting Idx else Idx = 1
crt @(iCol,iRow + Idx - 1):"*":
return


SelectOption:
PROMPT<1,PMT$COLUMN> = ""
PROMPT<1,PMT$ROW> = ""
PROMPT<1,PMT$PRINT.FLAG> = "B" ;*Bottom of the screen.
call SCREEN.IP(RESPONSE,PROMPT,"A","")
ANSWER = RESPONSE
return


STOP

999:* Abortion
*#* ABORT
STOP

END
