home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR19
/
SNIP0693.ZIP
/
ALERT.PRG
< prev
next >
Wrap
Text File
|
1992-09-06
|
2KB
|
106 lines
*
* show choices and wait for user to choose one
*
FUNCTION ALERT(param1,param2,param3)
*-----------------------------------------------------------------------------*
LOCAL row:=12,mess:='',prompts:={'OK'},mess_a:={}
LOCAL a,b,c,d,original
LOCAL max:=0,box_width:=0,x,y,choice:=0,prompt_width,max_mess:=0
LOCAL scr_buff,cur_color
ALERT__(param1,@row,@mess,@prompts)
ALERT__(param2,@row,@mess,@prompts)
ALERT__(param3,@row,@mess,@prompts)
original:=ACLONE(prompts)
a:=row
c:=a+4
DO WHILE !EMPTY(mess)
AADD(mess_a,STRIP_STRING(@mess,';'))
ENDDO
c+=IF(LEN(mess_a)==0,-1,LEN(mess_a)) - 1
AEVAL(mess_a,{ |v| max_mess:=MAX(max_mess,LEN(v)) })
AEVAL(prompts,{ |v| max:=MAX(max,LEN(v)) })
max+=4
prompt_width:=(max*LEN(prompts))+((LEN(prompts)+1)*2)+4
box_width:=MAX(max_mess+6,prompt_width)
AEVAL(prompts,{ |v,s| prompts[s]:=PADC(v,max) })
b:=(80-box_width)/2
d:=b+box_width-1
cur_color:=SETCOLOR()
IF ISCOLOR()
SETCOLOR("+W/R,+W/B")
ELSE
SETCOLOR("N/W,+W/N")
ENDIF
scr_buff:=SAVESCREEN(a,b,c,d)
@ a,b,c,d BOX "VD7:=DS: "
FOR x:=1 TO LEN(mess_a)
@ a+x,(80-LEN(mess_a[x]))/2 SAY mess_a[x]
NEXT
DO WHILE choice==0
y:=b+4+(box_width-prompt_width)/2
FOR x:=1 TO LEN(prompts)
@ c-1,y PROMPT prompts[x]
y+=max+2
NEXT
MENU TO choice
ENDDO
RESTSCREEN(a,b,c,d,scr_buff)
SETCOLOR(cur_color)
RETURN choice
*-----------------------------------------------------------------------------*
*
* assign parameters to its slots
*
STATIC FUNCTION ALERT__(param,row,mess,array)
*-----------------------------------------------------------------------------*
DO CASE
CASE VALTYPE(param)=='N'
row:=param
CASE VALTYPE(param)=='C'
mess:=param
CASE VALTYPE(param)=='A'
array:=ACLONE(param)
ENDCASE
RETURN NIL
*-----------------------------------------------------------------------------*
*
* extract token from passed string
*
FUNCTION STRIP_STRING(string,schr,elem)
*-----------------------------------------------------------------------------*
LOCAL x,nstr:='',chr
IF elem # NIL
FOR x:=1 TO elem-1
STRIP_STRING(@string,schr)
NEXT
ENDIF
FOR x:=1 TO LEN(string)
chr:=SUBSTR(string,x,1)
IF chr $ schr
EXIT
ENDIF
nstr+=chr
NEXT
string:=RIGHT(string,MAX(LEN(string)-x,0))
RETURN nstr