home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
451-475
/
apd453
/
rob's_alert_box.amos
/
rob's_alert_box.amosSourceCode
Wrap
AMOS Source Code
|
1993-01-08
|
7KB
|
219 lines
' AN ALERT BOX ROUTINE
' by Robert Iwancz
' O.K. Seriously now. Please feel free to use this procedure in your own
' programs. If you do, PLEASE give me a mention (if you do, PLEASE spell my
' surname right! I know it's hard).
' The main difference between this alert box and others I've seen is that
' this one opens its own (hires) screen. The screen number can be changed
' if screen 4 doesn't suit you. After the procedure call make sure you make
' the screen you were working with the current screen (E.g.: Screen 2).
' The number of the button that has been selected is returned in the variable
' GADGET. If you want you can make GADGET a parameter instead of a Global
' variable.
' This alert box has many disadvantages. You cannot specify the colours
' used or size of the alert box in the parameters, as you can with Aaron's.
' You can only have a maximum of 6 lines and 3 buttons. When the procedure
' is called, colour 1 is turned into a rainbow. If this is an advantage
' or disadvantage is a matter of personal preference (run this program to
' see what I mean).
' It is entirely up to you if the advantages outweigh the disadvantages.
' USAGE: ALERT[NB,NL,U,TITLE$l
' Where NB is the number of buttons, NL is the number of lines,
' U I'll explain in a moment, and TITLE$ is a title (e.g HELLO or
' SYSTEM MESSAGE, etc)
' If U is 0 then the lines are CENTREd, otherwise they are PRINTed.
'** IMPORTANT!!!--These two arrays must be dimensioned and made global before
'the procedure is called(at the begining of the program would be a good idea).
Dim LINE$(5),BUTTON$(3)
Global LINE$(),BUTTON$(),GADGET
' A bit of setting up so we have a functional demo of the procedure.
Screen Open 0,320,256,16,Lowres
Curs Off : Flash Off
Cls 2
Locate ,15
Reserve Zone 1
Pen 4 : Paper 5
Centre Border$(Zone$("Click here to see the alert box",1),2)
'Main Loop
Repeat
Inc CNT
Repeat : Until Mouse Key<>0 and Mouse Zone<>0
Proc DISPLAY_BOX[CNT]
If CNT=5 Then STUFFED=-1
Until STUFFED
' This procedure demonstrates how to use this alert box.
Procedure DISPLAY_BOX[NUM]
If NUM=1
LINE$(0)="AN ALERT BOX ROUTINE"
LINE$(1)="~~~~~~~~~~~~~~~~~~~~"
LINE$(2)="---���>>> by Robert Iwancz <<<���---"
LINE$(3)="----------------"
LINE$(4)="December 1991"
LINE$(5)="��� Written in AMOS ���"
BUTTON$(0)=" OK "
ALERT[1,6,0,"SYSTEM MESSAGE"]
Screen 0
Cls 1
Pen 0 : Paper 2
Locate ,10
Centre "Cls 1. Now note the rainbow."
Locate ,15
Pen 4 : Paper 5
Centre Border$(Zone$("Please click here again.",1),2)
End If
If NUM=2
LINE$(0)="See what happens when the"
LINE$(1)="screen is filled with colour 1"
BUTTON$(0)="Yes"
BUTTON$(1)="No"
Repeat
ALERT[2,2,1,"MESSAGE FROM ROB"]
Until GADGET=1
Screen 0
Cls 2
Pen 0 : Paper 2
Locate ,10
Centre "Let's try that with colour 2 (white)"
Locate ,15
Pen 4 : Paper 5
Centre Border$(Zone$("Please click here again.",1),2)
End If
If NUM=3
LINE$(0)=""
LINE$(1)=""
LINE$(2)="See the difference?"
BUTTON$(0)="Yes"
BUTTON$(1)="No"
Repeat
ALERT[2,3,1,"MESSAGE FROM ROB"]
Until GADGET=1
Screen 0
Cls 2
Pen 0 : Paper 2
Locate ,10
Centre "Next, U = 0"
Locate ,15
Pen 4 : Paper 5
Centre Border$(Zone$("Please click here again.",1),2)
End If
If NUM=4
LINE$(0)="Notice"
LINE$(1)="how"
LINE$(2)="this"
LINE$(3)="text "
LINE$(4)="is"
LINE$(5)="centered?"
BUTTON$(0)="Yes"
BUTTON$(1)="Yes"
BUTTON$(2)="Yes"
ALERT[3,6,0,"MESSAGE FROM ROB"]
Screen 0
Cls 2
Pen 0 : Paper 2
Locate ,10
Centre "Now, U = 1 "
Locate ,15
Pen 4 : Paper 5
Centre Border$(Zone$("Click here for the last time.",1),2)
End If
If NUM=5
LINE$(0)="Notice"
LINE$(1)="how"
LINE$(2)="this"
LINE$(3)="text "
LINE$(4)="is NOT"
LINE$(5)="centered?"
BUTTON$(0)="Yes"
BUTTON$(1)="Yes"
BUTTON$(2)="Yes"
ALERT[3,6,1,"MESSAGE FROM ROB"]
Screen 0
Cls 0
Pen 0 : Paper 2
Locate ,10
Centre "THE END"
Locate ,15
Pen 4 : Paper 5
Centre Border$(Zone$("Please DON'T click here again.",1),2)
End If
End Proc
'HERE IT IS! The actual routine! This is what all the fuss above is all about!
'** Written by Robert Iwancz **
Procedure ALERT[NB,NL,U,TITLE$]
Auto View Off
W=320 : H=103 : X=160 : Y=10
GADGET=0
On Menu Off : Menu Off
Volume 63
Play 1,13,0 : Play 2,25,0
Screen Open 4,640,150,8,Hires
Palette ,,,,$7,$DB,$FF0,$F00
Screen Display 4,140,100,,0
Set Rainbow 0,1,30,"(1,1,5)(1,-1,5)","(1,1,15)(1,-1,15)","(1,1,15)(1,-1,15)"
Rainbow 0,0,99,152
Channel 0 To Rainbow 0
Amal 0,"Loop: For RA=0 To 29; Let X=RA; P;P;P;P;P; Next RA; Jump Loop"
Amal On
Curs Off : Cls 1
Pen 0 : Locate ,0 : Centre TITLE$
Paper 4 : Pen 5
Ink 0 : Bar X+30,Y+30 To X+W+30,Y+H+30
Ink 4,,5 : Set Paint 1
Polygon X+1,Y+H+1 To X+15,Y+H+15 To X+W+15,Y+H+15 To X+W+15,Y+15 To X+W+1,Y+1
Wind Open 1,X,Y,40,13 : Curs Off
Ink 5 : Box X,Y To X+W,Y+H
Draw X+W+15,Y+H+15 To X+W,Y+H
If U=1
Locate ,1
For L=1 To NL
Locate 1, : Print LINE$(L-1)
Next L
Else
For L=1 To NL
Locate ,L : Centre LINE$(L-1)
Next L
End If
' Now we finally get to the buttons!
Reserve Zone NB
D=0 : S=40/(NB+1)
While D<>NB
XX=(S*(D+1)-1)-Len(BUTTON$(D))/2 : YY=9
Pen 0 : Paper 0 : Locate XX+1,YY+1
Print Border$(BUTTON$(D),2)
Pen 7 : Paper 6 : Locate XX,YY
Print Border$(Zone$(BUTTON$(D),D+1),2)
Inc D
Wend
Auto View On
For D=1 To 150 Step 3
Screen Display 4,140,100,,D
Wait Vbl
Next D
Screen Display 4,140,100,640,150
Change Mouse 1 : Screen 4 : Limit Mouse
Repeat
Z=Mouse Zone : K=Mouse Key
If Z<>OLDZ
If OLDZ>0 : HI=True : B=OLDZ-1 : OLDZ=-1 : Gosub A_HILITE : End If
If Z>0 : OLDZ=Z : HI=False : B=Z-1 : Gosub A_HILITE : End If
End If
Until K<>0 and Z<>0
GADGET=Z
Volume 63
Play 1,70,0 : Play 2,30,0
Play 3,70,0 : Play 4,30,0
For D=150 To 1 Step -3
Screen Display 4,140,100,,D
Wait Vbl
Next D
Wind Close
Amal Off : Rainbow Del
Reset Zone : Reserve Zone
Screen Close 4
Pop Proc
A_HILITE:
XX=(S*(B+1)-1)-Len(BUTTON$(B))/2 : YY=9
If HI=False Then Inverse On Else Inverse Off
Locate XX,YY : Print Border$(BUTTON$(B),2)
Return
End Proc