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
AMOS Source Code  |  1993-01-08  |  7KB  |  219 lines

  1. '                          AN ALERT BOX ROUTINE
  2. '                            by Robert Iwancz
  3. '   O.K.  Seriously now.  Please feel free to use this procedure in your own 
  4. ' programs.  If you do, PLEASE give me a mention (if you do, PLEASE spell my 
  5. ' surname right!  I know it's hard). 
  6. '   The main difference between this alert box and others I've seen is that
  7. ' this one opens its own (hires) screen.  The screen number can be changed 
  8. ' if screen 4 doesn't suit you.  After the procedure call make sure you make 
  9. ' the screen you were working with the current screen (E.g.: Screen 2).
  10. ' The number of the button that has been selected is returned in the variable
  11. ' GADGET.  If you want you can make GADGET a parameter instead of a Global 
  12. ' variable.
  13. '   This alert box has many disadvantages.  You cannot specify the colours 
  14. ' used or size of the alert box in the parameters, as you can with Aaron's.
  15. ' You can only have a maximum of 6 lines and 3 buttons.  When the procedure
  16. ' is called, colour 1 is turned into a rainbow.  If this is an advantage 
  17. ' or disadvantage is a matter of personal preference (run this program to
  18. ' see what I mean).
  19. '   It is entirely up to you if the advantages outweigh the disadvantages. 
  20. ' USAGE:  ALERT[NB,NL,U,TITLE$l
  21. '       Where NB is the number of buttons,  NL is the number of lines, 
  22. '       U I'll explain in a moment, and TITLE$ is a title (e.g HELLO or
  23. '       SYSTEM MESSAGE, etc) 
  24. '       If U is 0 then the lines are CENTREd, otherwise they are PRINTed.
  25. '** IMPORTANT!!!--These two arrays must be dimensioned and made global before
  26. 'the procedure is called(at the begining of the program would be a good idea). 
  27. Dim LINE$(5),BUTTON$(3)
  28. Global LINE$(),BUTTON$(),GADGET
  29. ' A bit of setting up so we have a functional demo of the procedure. 
  30. Screen Open 0,320,256,16,Lowres
  31. Curs Off : Flash Off 
  32. Cls 2
  33. Locate ,15
  34. Reserve Zone 1
  35. Pen 4 : Paper 5
  36. Centre Border$(Zone$("Click here to see the alert box",1),2)
  37. 'Main Loop 
  38. Repeat 
  39.    Inc CNT
  40.    Repeat : Until Mouse Key<>0 and Mouse Zone<>0
  41.    Proc DISPLAY_BOX[CNT]
  42.    If CNT=5 Then STUFFED=-1
  43. Until STUFFED
  44. ' This procedure demonstrates how to use this alert box. 
  45. Procedure DISPLAY_BOX[NUM]
  46.    If NUM=1
  47.       LINE$(0)="AN ALERT BOX ROUTINE"
  48.       LINE$(1)="~~~~~~~~~~~~~~~~~~~~"
  49.       LINE$(2)="---���>>> by Robert Iwancz <<<���---"
  50.       LINE$(3)="----------------"
  51.       LINE$(4)="December 1991"
  52.       LINE$(5)="��� Written in AMOS ï¿½ï¿½ï¿½"
  53.       BUTTON$(0)="  OK  "
  54.       ALERT[1,6,0,"SYSTEM MESSAGE"]
  55.       Screen 0
  56.       Cls 1
  57.       Pen 0 : Paper 2
  58.       Locate ,10
  59.       Centre "Cls 1.  Now note the rainbow."
  60.       Locate ,15
  61.       Pen 4 : Paper 5
  62.       Centre Border$(Zone$("Please click here again.",1),2)
  63.    End If 
  64.    If NUM=2
  65.       LINE$(0)="See what happens when the"
  66.       LINE$(1)="screen is filled with colour 1"
  67.       BUTTON$(0)="Yes"
  68.       BUTTON$(1)="No"
  69.       Repeat 
  70.          ALERT[2,2,1,"MESSAGE FROM ROB"]
  71.       Until GADGET=1
  72.       Screen 0
  73.       Cls 2
  74.       Pen 0 : Paper 2
  75.       Locate ,10
  76.       Centre "Let's try that with colour 2 (white)"
  77.       Locate ,15
  78.       Pen 4 : Paper 5
  79.       Centre Border$(Zone$("Please click here again.",1),2)
  80.    End If 
  81.    If NUM=3
  82.       LINE$(0)=""
  83.       LINE$(1)=""
  84.       LINE$(2)="See the difference?"
  85.       BUTTON$(0)="Yes"
  86.       BUTTON$(1)="No"
  87.       Repeat 
  88.          ALERT[2,3,1,"MESSAGE FROM ROB"]
  89.       Until GADGET=1
  90.       Screen 0
  91.       Cls 2
  92.       Pen 0 : Paper 2
  93.       Locate ,10
  94.       Centre "Next, U = 0"
  95.       Locate ,15
  96.       Pen 4 : Paper 5
  97.       Centre Border$(Zone$("Please click here again.",1),2)
  98.    End If 
  99.    If NUM=4
  100.       LINE$(0)="Notice"
  101.       LINE$(1)="how"
  102.       LINE$(2)="this"
  103.       LINE$(3)="text "
  104.       LINE$(4)="is"
  105.       LINE$(5)="centered?"
  106.       BUTTON$(0)="Yes"
  107.       BUTTON$(1)="Yes"
  108.       BUTTON$(2)="Yes"
  109.       ALERT[3,6,0,"MESSAGE FROM ROB"]
  110.       Screen 0
  111.       Cls 2
  112.       Pen 0 : Paper 2
  113.       Locate ,10
  114.       Centre "Now, U = 1   "
  115.       Locate ,15
  116.       Pen 4 : Paper 5
  117.       Centre Border$(Zone$("Click here for the last time.",1),2)
  118.    End If 
  119.    If NUM=5
  120.       LINE$(0)="Notice"
  121.       LINE$(1)="how"
  122.       LINE$(2)="this"
  123.       LINE$(3)="text "
  124.       LINE$(4)="is NOT"
  125.       LINE$(5)="centered?"
  126.       BUTTON$(0)="Yes"
  127.       BUTTON$(1)="Yes"
  128.       BUTTON$(2)="Yes"
  129.       ALERT[3,6,1,"MESSAGE FROM ROB"]
  130.       Screen 0
  131.       Cls 0
  132.       Pen 0 : Paper 2
  133.       Locate ,10
  134.       Centre "THE END"
  135.       Locate ,15
  136.       Pen 4 : Paper 5
  137.       Centre Border$(Zone$("Please DON'T click here again.",1),2)
  138.    End If 
  139. End Proc
  140. 'HERE IT IS! The actual routine! This is what all the fuss above is all about! 
  141. '**  Written by Robert Iwancz  **        
  142. Procedure ALERT[NB,NL,U,TITLE$]
  143.    Auto View Off 
  144.    W=320 : H=103 : X=160 : Y=10
  145.    GADGET=0
  146.    On Menu Off : Menu Off 
  147.    Volume 63
  148.    Play 1,13,0 : Play 2,25,0
  149.    Screen Open 4,640,150,8,Hires
  150.    Palette ,,,,$7,$DB,$FF0,$F00
  151.    Screen Display 4,140,100,,0
  152.    Set Rainbow 0,1,30,"(1,1,5)(1,-1,5)","(1,1,15)(1,-1,15)","(1,1,15)(1,-1,15)"
  153.    Rainbow 0,0,99,152
  154.    Channel 0 To Rainbow 0
  155.    Amal 0,"Loop: For RA=0 To 29; Let X=RA; P;P;P;P;P; Next RA; Jump Loop"
  156.    Amal On 
  157.    Curs Off : Cls 1
  158.    Pen 0 : Locate ,0 : Centre TITLE$
  159.    Paper 4 : Pen 5
  160.    Ink 0 : Bar X+30,Y+30 To X+W+30,Y+H+30
  161.    Ink 4,,5 : Set Paint 1
  162.    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
  163.    Wind Open 1,X,Y,40,13 : Curs Off 
  164.    Ink 5 : Box X,Y To X+W,Y+H
  165.    Draw X+W+15,Y+H+15 To X+W,Y+H
  166.    If U=1
  167.       Locate ,1
  168.       For L=1 To NL
  169.          Locate 1, : Print LINE$(L-1)
  170.       Next L
  171.    Else 
  172.       For L=1 To NL
  173.          Locate ,L : Centre LINE$(L-1)
  174.       Next L
  175.    End If 
  176.    ' Now we finally get to the buttons! 
  177.    Reserve Zone NB
  178.    D=0 : S=40/(NB+1)
  179.    While D<>NB
  180.       XX=(S*(D+1)-1)-Len(BUTTON$(D))/2 : YY=9
  181.       Pen 0 : Paper 0 : Locate XX+1,YY+1
  182.       Print Border$(BUTTON$(D),2)
  183.       Pen 7 : Paper 6 : Locate XX,YY
  184.       Print Border$(Zone$(BUTTON$(D),D+1),2)
  185.       Inc D
  186.    Wend 
  187.    Auto View On 
  188.    For D=1 To 150 Step 3
  189.       Screen Display 4,140,100,,D
  190.       Wait Vbl 
  191.    Next D
  192.    Screen Display 4,140,100,640,150
  193.    Change Mouse 1 : Screen 4 : Limit Mouse 
  194.    Repeat 
  195.       Z=Mouse Zone : K=Mouse Key
  196.       If Z<>OLDZ
  197.          If OLDZ>0 : HI=True : B=OLDZ-1 : OLDZ=-1 : Gosub A_HILITE : End If 
  198.          If Z>0 : OLDZ=Z : HI=False : B=Z-1 : Gosub A_HILITE : End If 
  199.       End If 
  200.    Until K<>0 and Z<>0
  201.    GADGET=Z
  202.    Volume 63
  203.    Play 1,70,0 : Play 2,30,0
  204.    Play 3,70,0 : Play 4,30,0
  205.    For D=150 To 1 Step -3
  206.       Screen Display 4,140,100,,D
  207.       Wait Vbl 
  208.    Next D
  209.    Wind Close 
  210.    Amal Off : Rainbow Del 
  211.    Reset Zone : Reserve Zone 
  212.    Screen Close 4
  213.    Pop Proc
  214.    A_HILITE:
  215.    XX=(S*(B+1)-1)-Len(BUTTON$(B))/2 : YY=9
  216.    If HI=False Then Inverse On Else Inverse Off 
  217.    Locate XX,YY : Print Border$(BUTTON$(B),2)
  218.    Return 
  219. End Proc