Set Buffer 30
'
' ***********************************  
' *** AMOS Dialog Procedures V3.6 ***  Written By John.A.Kinsella  
' ***********************************  
'
' *** SET VARIABLES HERE ****************************************************
'
_DIALOGBUTTON$=""
A#=0.0 : Rem Compiler Fix.
'
_MAXFILES=200
_FILES=0
_PATH$="Ram:"
_WILD$="**"
_FILE$=""
Dim _FILENAME$(_MAXFILES)
'
' *** SET GLOBAL VARIABLES HERE *********************************************
'
Global A#
'
' *** Open Default Screen & Set Font.
'
_OPENDIALOGSCREEN[0,256,44]
'
Limit Mouse 128,44 To 447,298
'
Get Rom Fonts 
_SETFONT["Topaz",8]
'
' *** INSERT PROGRAM BELOW THIS LINE ****************************************
'
'
' *** INSERT PROGRAM ABOVE THIS LINE ****************************************
'
Screen Close 0
End 
'
Procedure _OPENDIALOGSCREEN[N,H,Y]
   '
   Shared _BACK,_SHADOW,_LIGHT,_COLOUR,_TEXT
   '
   Screen Open N,640,H,4,Hires
   Screen Display N,130,Y,,
   Curs Off 
   Flash Off 
   Cls 0
   Palette $AAA,$0,$FFF,$58B
   '
   Colour Back Colour(0)
   '
   _BACK=0
   _SHADOW=1
   _LIGHT=2
   _COLOUR=3
   _TEXT=1
   '
   Pen _TEXT
   Paper _BACK
   Ink _TEXT,_BACK
   '
   ' *** Set Mouse Colours. 
   '
   Colour 17,$EEC
   Colour 18,$0
   Colour 19,$E44
   '
End Proc
'
Procedure _DRAW3DBOX[X1,Y1,X2,Y2,T$,IN,FC,BC]
   '
   Shared _SHADOW,_LIGHT
   '
   If IN=0 or IN=3
      C1=_SHADOW
      C2=_LIGHT
   Else 
      C1=_LIGHT
      C2=_SHADOW
   End If 
   '
   If IN<>2
      Ink BC,FC
      Bar X1,Y1 To X2,Y2
      Ink C1
      Box X1,Y1 To X2,Y2
      If IN<3
         Box X1+1,Y1 To X2-1,Y2
      End If 
      Ink C2
      Polyline X1+1,Y2 To X2,Y2 To X2,Y1
      If IN<3
         Polyline X1+1,Y2 To X2-1,Y2 To X2-1,Y1+1
      End If 
   Else 
      Cls BC,X1+2,Y1+1 To X2-1,Y2
   End If 
   '
   I=0
   J=0
   B=0
   While I<Len(T$)
      I=Instr(T$,"|",I+1)
      If I=0
         I=Len(T$)+1
      End If 
      J=I
      Inc B
   Wend 
   '
   If Upper$(Left$(T$,3))="(S)"
      _DRAWUSEROBJECT[X1,Y1,X2,Y2,Mid$(T$,4)]
      Goto FIN
   End If 
   '
   H#=((Y2-Y1)-(B*Text Base))/(B+1)
   Y#=Y1+H#+Text Base
   '
   Ink FC,BC
   Gr Writing 0
   '
   I=0
   J=0
   LOP=0
   While LOP<B
      I=Instr(T$,"|",I+1)
      If I=0
         I=Len(T$)+1
      End If 
      A$=Mid$(T$,J+1,I-J-1)
      '
      If Left$(A$,1)="'"
         A$=Mid$(A$,2)
         X7=X1+4
         Goto NXT
      End If 
      '
      If Left$(A$,1)="^"
         A$=Mid$(A$,2)
         X7=(X2-Text Length(A$))-4
         Goto NXT
      End If 
      '
      WID=Text Length(A$)
      X7=(((X2-X1)/2)+X1)-(WID/2)+1
      '
      NXT:
      Text X7,Y#,A$
      '
      Y#=Y#+Text Base+H#
      '
      J=I
      Inc LOP
   Wend 
   '
   Gr Writing 1
   '
   FIN:
   '
End Proc
'
Procedure _CHECKZONE[X1,Y1,X2,Y2,WT]
   '
   X=X Screen(X Mouse)
   Y=Y Screen(Y Mouse)
   M=Mouse Key
   AN=0
   '
   If X<X1 or X>X2 or Y<Y1 or Y>Y2 or M=0
      Goto FIN2
   End If 
   '
   AN=M
   '
   If WT=0
      Goto FIN2
   End If 
   '
   If WT=1
      Gr Writing 2
      Bar X1,Y1 To X2,Y2
   End If 
   '
   While X>=X1 and X<=X2 and Y>=Y1 and Y<=Y2
      X=X Screen(X Mouse)
      Y=Y Screen(Y Mouse)
      If Mouse Key=0
         Goto FIN
      End If 
   Wend 
   '
   AN=0
   '
   FIN:
   If WT=1
      Bar X1,Y1 To X2,Y2
      Gr Writing 1
   End If 
   '
   FIN2:
   '
End Proc[AN]
'
Procedure _SETFONT[FT$,FS]
   '
   Shared _FONTNAME$,_FONTSIZE
   '
   FT$=Upper$(FT$)
   '
   OK=0
   POS=1
   '
   While Font$(POS)<>""
      If Upper$(Left$(Font$(POS),Len(FT$)+5))=(FT$+".FONT")
         If Val(Mid$(Font$(POS),30,3))=FS
            Set Font POS
            OK=1
            _FONTNAME$=FT$
            _FONTSIZE=FS
         End If 
      End If 
      Inc POS
   Wend 
   '
End Proc[OK]
'
Procedure _ADDBUTTON[X1,Y1,X2,Y2,T$,BZ]
   '
   Shared _TEXT,_BACK
   '
   _DRAW3DBOX[X1,Y1,X2,Y2,T$,1,_TEXT,_BACK]
   '
   If BZ<>0
      _ADDZONE[X1,Y1,X2,Y2,BZ,"B"]
   End If 
   '
End Proc
'
Procedure _CHECKBUTTONS
   '
   Shared _DIALOGBUTTON$
   '
   ZN=0
   I1=1
   I2=1
   '
   While I2<Len(_DIALOGBUTTON$)
      '
      I2=Instr(_DIALOGBUTTON$,";",I1)
      L$=Mid$(_DIALOGBUTTON$,I1,I2-I1)
      '
      AC=Asc(Mid$(L$,1,1))
      X1=Val(Mid$(L$,3,3))
      Y1=Val(Mid$(L$,7,3))
      X2=Val(Mid$(L$,11,3))
      Y2=Val(Mid$(L$,15,3))
      BZ=Val(Mid$(L$,19,4))
      '
      WT=1
      If BZ<0
         BZ=-BZ
         WT=0
      End If 
      '
      _CHECKZONE[X1,Y1,X2,Y2,WT]
      If Param and(AC>64 and AC<91) : Rem A to Z.
         ZN=BZ
         Goto FIN
      End If 
      '
      I1=I2+1
      '
   Wend 
   '
   FIN:
   '
End Proc[ZN]
'
Procedure _DELETEBUTTON[NO,BC]
   '
   Shared _DIALOGBUTTON$
   '
   I1=1
   I2=1
   '
   If NO<0
      NO=-NO
   End If 
   '
   While I2<Len(_DIALOGBUTTON$)
      '
      I2=Instr(_DIALOGBUTTON$,";",I1)
      L$=Mid$(_DIALOGBUTTON$,I1,I2-I1)
      '
      BZ=Val(Mid$(L$,19,3))
      If BZ<0
         BZ=-BZ
      End If 
      '
      If BZ=NO
         '
         X1=Val(Mid$(L$,3,3))
         Y1=Val(Mid$(L$,7,3))
         X2=Val(Mid$(L$,11,3))
         Y2=Val(Mid$(L$,15,3))
         '
         _DIALOGBUTTON$=Left$(_DIALOGBUTTON$,I1-1)+Mid$(_DIALOGBUTTON$,I2+1)
         '
         If BC>-1
            Ink BC
            Bar X1,Y1 To X2,Y2
         End If 
         '
      End If 
      '
      I1=I2+1
      '
   Wend 
   '
End Proc
'
Procedure _ADDTICKBOX[X1,Y1,PO,BZ]
   '
   Shared _SHADOW,_TEXT,_BACK
   '
   _DRAW3DBOX[X1,Y1,X1+26,Y1+11,"",1,_TEXT,_BACK]
   '
   If BZ=0
      PO=1-PO
   End If 
   '
   If BZ<>0
      _ADDZONE[X1,Y1,X1+26,Y1+11,BZ,"T"]
   End If 
   '
   If PO=1
      Ink _SHADOW
      X1=X1+7
      Y1=Y1+2
      Draw X1,Y1+3 To X1+3,Y1+6
      Draw X1+1,Y1+3 To X1+4,Y1+6
      Draw X1+2,Y1+3 To X1+5,Y1+6
      Draw X1+10,Y1 To X1+12,Y1
      Draw X1+10,Y1+1 To X1+6,Y1+5
      Draw X1+9,Y1+1 To X1+5,Y1+5
   End If 
   '
End Proc[PO]
'
Procedure _ADDTICKBUTTON[X1,Y1,X2,Y2,T$,PO,BZ]
   '
   Shared _TEXT,_BACK
   '
   _DRAW3DBOX[X1,Y1,X2,Y2,T$,1,_TEXT,_BACK]
   '
   If BZ=0
      PO=1-PO
   End If 
   '
   If BZ<>0
      _ADDZONE[X1,Y1,X2,Y2,BZ,"U"]
   End If 
   '
   If PO=1
      Gr Writing 2
      Bar X1,Y1 To X2,Y2
      Gr Writing 1
   End If 
   '
End Proc[PO]
'
Procedure _ADDCYCLEBUTTON[X1,Y1,X2,Y2,T$,PO,BZ]
   '
   Shared _SHADOW,_LIGHT,_TEXT,_BACK
   '
   T$=T$+"|"
   I1=1
   I2=1
   P=1
   '
   I=0
   IO=0
   B=0
   While I<Len(T$)
      I=Instr(T$,"|",I+1)
      If I=0
         I=Len(T$)+1
      End If 
      IO=I
      B=B+1
   Wend 
   '
   If BZ=0
      Add PO,1,1 To B
   End If 
   '
   While I2<Len(T$)
      I2=Instr(T$,"|",I1)
      If P=PO
         L$=Mid$(T$,I1,I2-I1)
         Exit 
      End If 
      I1=I2+1
      Inc P
   Wend 
   '
   _DRAW3DBOX[X1,Y1,X2,Y2,"",1,_TEXT,_BACK]
   If BZ<>0
      _ADDZONE[X1,Y1,X2,Y2,BZ,"C"]
   End If 
   '
   Ink _SHADOW
   X1=X1+6
   Y1=Y1+2
   Y2=Y2-3
   Draw X1+1,Y1 To X1+7,Y1
   Draw X1,Y1+1 To X1,Y2-1
   Draw X1+1,Y1+1 To X1+1,Y2-1
   Draw X1+1,Y2 To X1+7,Y2
   Draw X1+7,Y2-1 To X1+8,Y2-1
   Draw X1+7,Y1+1 To X1+7,Y1+5
   Draw X1+8,Y1+1 To X1+8,Y1+5
   Draw X1+5,Y1+3 To X1+10,Y1+3
   Draw X1+6,Y1+4 To X1+9,Y1+4
   Draw X1+14,Y1 To X1+14,Y2+1
   Ink _LIGHT
   Draw X1+15,Y1 To X1+15,Y2+1
   '
   _DRAW3DBOX[X1+16,Y1-2,X2,Y2+3,L$,2,_TEXT,_BACK]
   '
End Proc[PO]
'
Procedure _ADDINPUTBUTTON[X1,Y1,TXT$,L,ML,BZ]
   '
   Shared _TEXT,_BACK,_FONTNAME$,_FONTSIZE
   '
   XX=X1+2
   YY=Y1+1
   ED$=TXT$
   SX=L
   '
   Ink _TEXT,_BACK
   '
   X1=X1-4
   Y1=Y1-3
   X2=X1+(L*8)+8+4
   Y2=Y1+13
   '
   TEMP2$=_FONTNAME$
   TEMP3=_FONTSIZE
   _SETFONT["Topaz",8]
   '
   If BZ<>0
      If BZ<>999
         _ADDZONE[X1,Y1,X2,Y2,BZ,"I"]
      End If 
      _DRAW3DBOX[X1,Y1,X2,Y2,"",1,_TEXT,_BACK]
      _DRAW3DBOX[X1+2,Y1+1,X2-2,Y2-1,"",0,_TEXT,_BACK]
      Gosub _DED
      Goto _END
   End If 
   '
   XC=Len(ED$)
   MN=0
   PX=0
   L=XC
   '
   Clear Key 
   '
   Do 
      Gosub _DED
      '
      If Mouse Key=1
         X=((X Screen(X Mouse)-(X1+5))/8)
         If X>=0 and X<=L
            XC=X
            Gosub _DED
         End If 
      End If 
      '
      Gr Writing 2
      Bar GRX,GRY To GRX+7,GRY+7
      '
      If Mouse Key
         Repeat 
         Until Mouse Key=0
      End If 
      '
      Repeat 
         A$=Inkey$
         S=Scancode
         K=Key Shift
      Until A$<>"" or Mouse Key or(A$<>"" and K)
      '
      XM=X Screen(X Mouse)
      YM=Y Screen(Y Mouse)
      If Mouse Key and(XM<X1 or XM>X2 or YM<Y1 or YM>Y2)
         A$=Chr$(13)
      End If 
      '
      Bar GRX,GRY To GRX+7,GRY+7
      Gr Writing 1
      '
      F=1
      '
      If A$=Chr$(13)
         Exit 
      End If 
      '
      If A$=Chr$(27)
         ED$=TXT$
         TXT$=""
         Gosub _DED
         Exit 
      End If 
      '
      If S=65 and K=0 and XC+PX>MN
         ED$=Left$(ED$,XC+PX-1)+Mid$(ED$,PX+XC+1)
         E=1
         Dec L
         S=79
      End If 
      '
      If S=65 and K>0 and K<4
         ED$=Mid$(ED$,PX+XC+1)
         L=Len(ED$)
         PX=0
         XC=0
      End If 
      '
      If S=70 and K=0 and XC+PX<L
         ED$=Left$(ED$,XC+PX)+Mid$(ED$,PX+XC+2)
         E=1
         Dec L
      End If 
      '
      If S=70 and K>0 and K<4
         ED$=Left$(ED$,XC+PX)
         L=Len(ED$)
         F=0
      End If 
      '
      If S=79 and PX+XC>MN
         F=0
         If XC=0
            Dec PX
         Else 
            Dec XC
         End If 
      End If 
      '
      If S=79 and K>0 and K<4
         F=0
         PX=0
         XC=0
      End If 
      '
      If S=78 and PX+XC<L
         F=0
         If XC=SX
            Inc PX
         Else 
            Inc XC
         End If 
      End If 
      '
      If S=78 and K>0 and K<4
         F=0
         XC=L
         If XC>SX
            XC=SX
         End If 
         PX=L-SX
         If PX<0
            PX=0
         End If 
      End If 
      '
      If F
         If A$>=" " and L<ML
            ED$=Left$(ED$,PX+XC)+A$+Mid$(ED$,PX+XC+1)
            Inc L
            If L>SX
               If XC>=SX
                  Inc PX
               Else 
                  Inc XC
               End If 
            Else 
               Inc XC
            End If 
         End If 
      End If 
      '
   Loop 
   '
   Goto _END
   '
   _DED:
   _DRAW3DBOX[X1+2,Y1+1,X2-2,Y2-1,"'"+Mid$(ED$,PX+1,SX),2,_TEXT,_BACK]
   GRX=X1+(XC*8)+6
   GRY=Y1+3
   Return 
   '
   _END:
   _DRAW3DBOX[X1+2,Y1+1,X2-2,Y2-1,"'"+Left$(ED$,SX),2,_TEXT,_BACK]
   '
   _SETFONT[TEMP2$,TEMP3]
   '
End Proc[ED$]
'
Procedure _DRAWUSEROBJECT[X1,Y1,X2,Y2,T$]
   '
   Shared _FONTNAME$,_FONTSIZE,_SHADOW,_LIGHT,_TEXT,_BACK,_COLOUR
   '
   Left$(T$,3)=Upper$(Left$(T$,3))
   '
   ' *** Paste Icon.
   '
   If Mid$(T$,1,3)="ICO"
      NO=Val(Mid$(T$,4,3))
      If Length(2)>=NO
         Paste Icon X1+Val(Mid$(T$,7,3)),Y1+Val(Mid$(T$,10,3)),NO
      End If 
   End If 
   '
   ' *** Paste Bob. 
   '
   If Mid$(T$,1,3)="BOB"
      NO=Val(Mid$(T$,4,3))
      If Length(1)>=NO
         Paste Bob X1+Val(Mid$(T$,7,3)),Y1+Val(Mid$(T$,10,3)),NO
      End If 
   End If 
   '
   ' *** Up Arrow.
   '
   If T$="UAR"
      Ink _SHADOW
      X=X1+(X2-X1)/2
      Y=Y1+(Y2-Y1)/2
      Polygon X,Y1+2 To X1+4,Y2-2 To X,Y To X2-4,Y2-2 To X,Y1+2
   End If 
   '
   ' *** Down Arrow.
   '
   If T$="DAR"
      Ink _SHADOW
      X=X1+(X2-X1)/2
      Y=Y1+(Y2-Y1)/2
      Polygon X,Y2-2 To X1+4,Y1+2 To X,Y To X2-4,Y1+2 To X,Y2-2
   End If 
   '
   ' *** Left Arrow.
   '
   If T$="LAR"
      Ink _SHADOW
      X=X1+(X2-X1)/2
      Y=Y1+(Y2-Y1)/2
      Polygon X1+4,Y To X2-4,Y1+2 To X,Y To X2-4,Y2-2 To X1+4,Y
   End If 
   '
   ' *** Right Arrow. 
   '
   If T$="RAR"
      Ink _SHADOW
      X=X1+(X2-X1)/2
      Y=Y1+(Y2-Y1)/2
      Polygon X2-4,Y To X1+4,Y1+2 To X,Y To X1+4,Y2-2 To X2-4,Y
   End If 
   '
   ' *** Group Box. 
   '
   If T$="GBX"
      _DRAW3DBOX[X1,Y1,X2,Y2,"",0,0,_BACK]
      _DRAW3DBOX[X1+2,Y1+1,X2-2,Y2-1,"",1,0,_BACK]
   End If 
   '
   ' *** Window.
   '
   If Mid$(T$,1,3)="WIN"
      _DRAW3DBOX[X1,Y1,X2,Y2,"",4,0,_COLOUR]
      _DRAW3DBOX[X1+3,Y1+10,X2-3,Y2-1,"",3,_LIGHT,_BACK]
      _DRAW3DBOX[X1,Y1,X2,Y1+10,Mid$(T$,4),4,_LIGHT,_COLOUR]
   End If 
   '
   ' *** File Icon. 
   '
   If Mid$(T$,1,3)="FIL"
      X1=X1+4
      Y1=Y1+2
      Ink _SHADOW
      Draw X1,Y1+2 To X1,Y1+8
      Draw X1+1,Y1+2 To X1+1,Y1+8
      Draw X1+2,Y1+8 To X1+11,Y1+8
      Draw X1+11,Y1+8 To X1+11,Y1+2
      Plot X1+10,Y1+1
      Plot X1+5,Y1+1
      Draw X1+6,Y1 To X1+9,Y1
      Draw X1+2,Y1+2 To X1+4,Y1+2
      Draw X1+2,Y1+3 To X1+5,Y1+3
      Draw X1+6,Y1+4 To X1+10,Y1+4
   End If 
   '
End Proc
'
Procedure _ADDRADIOBUTTON[X,Y,GP,BN,PO,BZ]
   '
   Shared _LIGHT,_SHADOW,_COLOUR,_BACK
   '
   X1=X
   Y1=Y
   '
   If PO=0
      C1=_LIGHT
      C2=_SHADOW
      C3=_COLOUR
   Else 
      C1=_SHADOW
      C2=_LIGHT
      C3=_BACK
   End If 
   '
   Ink C1
   Draw X1+14,Y1 To X1+14,Y1+1
   Draw X1+15,Y1+1 To X1+15,Y1+7
   Draw X1+16,Y1+2 To X1+16,Y1+6
   Draw X1+14,Y1+7 To X1+15,Y1+7
   Draw X1+14,Y1+8 To X1+3,Y1+8
   Ink C2
   Draw X1+13,Y1 To X1+2,Y1
   Draw X1+2,Y1+1 To X1+1,Y1+1
   Draw X1,Y1+2 To X1,Y1+6
   Draw X1+1,Y1+2 To X1+1,Y1+7
   Draw X1+2,Y1+7 To X1+2,Y1+8
   Ink C3
   Draw X1+4,Y1+3 To X1+4,Y1+5
   Draw X1+12,Y1+3 To X1+12,Y1+5
   Bar X1+5,Y1+2 To X1+11,Y1+6
   '
   If BZ<>0
      '
      L$=Space$(8)
      '
      Mid$(L$,2,2)=Str$(GP)-" "
      Mid$(L$,5,2)=Str$(BN)-" "
      Mid$(L$,8,1)=Str$(PO)-" "
      '
      _ADDZONE[X,Y,X+16,Y+8,BZ,"R"+L$]
      '
   End If 
   '
End Proc
'
Procedure _SETRADIO[BZ]
   '
   Shared _DIALOGBUTTON$
   '
   _GETBUTTONSTRING[BZ]
   F$=Param$
   '
   GN=Val(Mid$(F$,24,2))
   BA=Val(Mid$(F$,27,2))
   '
   I1=1
   I2=1
   '
   While I2<Len(_DIALOGBUTTON$)
      '
      I2=Instr(_DIALOGBUTTON$,";",I1)
      L$=Mid$(_DIALOGBUTTON$,I1,I2-I1)
      '
      A$=Left$(L$,1)
      GP=Val(Mid$(L$,24,2))
      '
      If((GP=GN) and((A$="R") or(A$="R")))
         '
         X1=Val(Mid$(L$,3,3))
         Y1=Val(Mid$(L$,7,3))
         BN=Val(Mid$(L$,27,2))
         '
         If BN=BA
            _ADDRADIOBUTTON[X1,Y1,BN,GP,0,0]
         Else 
            _ADDRADIOBUTTON[X1,Y1,BN,GP,1,0]
         End If 
      End If 
      '
      I1=I2+1
      '
   Wend 
   '
End Proc
'
Procedure _VERTICALSLIDER[X,Y,W,H,S,P,T$]
   '
   Shared _TEXT,_BACK,_TEXT
   '
   _DRAW3DBOX[X,Y,X+W,Y+H,"",4,_TEXT,_BACK]
   HIG=0
   '
   If S>=1
      T=Y+(H*(P-1))/S
      B=Min(Y+H,T+H/S)
      If B-T<3
         T=Y+((H-3)*(P-1))/S
         B=Min(Y+(H-3),T+(H-3)/S)
         HIG=3
      End If 
      Cls _TEXT,X+3,T+1 To X+W-2,B+1+HIG
   End If 
   '
   If T$<>""
      _SLIDERROUTINE[T$,P]
   End If 
   '
End Proc
'
Procedure _GRABVERTICALSLIDER[X,Y,W,H,S,P,T$]
   '
   If S<1 Then Pop Proc
   '
   T=Y+(H*(P-1))/S
   B=Min(Y+H,T+H/S)
   '
   _CHECKZONE[X,Y,X+W,T-1,2]
   If Param>0 and P>1
      Dec P
      Gosub _DRAWSLIDER
      Goto FIN
   End If 
   '
   _CHECKZONE[X,B+1,X+W,Y+H,2]
   If Param and P<S
      Inc P
      Gosub _DRAWSLIDER
      Goto FIN
   End If 
   '
   _CHECKZONE[X,T,X+W,B,0]
   If Param>0
      '
      PO=P
      DY=Y Screen(Y Mouse)-T
      '
      Repeat 
         '
         YY=Y Screen(Y Mouse)-Y-DY
         PO=((YY*(S+1))/H+1)
         '
         If PO<1
            PO=1
         End If 
         If PO>S
            PO=S
         End If 
         '  
         If PO<>P
            P=PO
            Gosub _DRAWSLIDER
         End If 
         '
      Until Mouse Key=0
   End If 
   '
   Goto FIN
   '
   _DRAWSLIDER:
   _VERTICALSLIDER[X,Y,W,H,S,P,""]
   Return 
   '
   FIN:
   '
End Proc[P]
'
Procedure _HORIZONTALSLIDER[X,Y,W,H,S,P,T$]
   '
   Shared _TEXT,_BACK,_TEXT
   '
   _DRAW3DBOX[X,Y,X+W,Y+H,"",4,_TEXT,_BACK]
   WID=0
   '
   If S>=1
      T=X+(W*(P-1))/S
      B=Min(X+W,T+W/S)
      If B-T<6
         T=X+((W-6)*(P-1))/S
         B=Min(X+(W-6),T+(W-6)/S)
         WID=6
      End If 
      Cls _TEXT,T+1,Y+2 To B+1+WID,Y+H-1
   End If 
   '
   If T$<>""
      _SLIDERROUTINE[T$,P]
   End If 
   '
End Proc
'
Procedure _GRABHORIZONTALSLIDER[X,Y,W,H,S,P,T$]
   '
   If S<1 Then Pop Proc
   '
   T=X+(W*(P-1))/S
   B=Min(X+W,T+W/S)
   '
   _CHECKZONE[X,Y,T-1,Y+H,2]
   If Param>0 and P>1
      Dec P
      Gosub _DRAWSLIDER
      Goto FIN
   End If 
   '
   _CHECKZONE[B+1,Y,X+W,Y+H,2]
   If Param>0 and P<S
      Inc P
      Gosub _DRAWSLIDER
      Goto FIN
   End If 
   '
   _CHECKZONE[T,Y,B,Y+H,0]
   If Param>0
      '
      PO=P
      DX=X Screen(X Mouse)-T
      '
      Repeat 
         '
         XX=X Screen(X Mouse)-X-DX
         PO=((XX*(S+1))/W+1)
         '
         If PO<1
            PO=1
         End If 
         If PO>S
            PO=S
         End If 
         '  
         If PO<>P
            P=PO
            Gosub _DRAWSLIDER
         End If 
         '
      Until Mouse Key=0
   End If 
   '
   Goto FIN
   '
   _DRAWSLIDER:
   _HORIZONTALSLIDER[X,Y,W,H,S,P,""]
   Return 
   '
   FIN:
   '
End Proc[P]
'
Procedure _SLIDERROUTINE[T$,P]
   '
   Shared _FONTNAME$,_FONTSIZE,_COLOUR,_SHADOW,_LIGHT,_BACK,_TEXT
   '
   Goto T$
   Goto FIN
   '
   '
   FIN:
   '
End Proc
'
Procedure _DRAWTITLEBAR[T$]
   '
   Shared _FONTNAME$,_FONTSIZE,_SHADOW,_LIGHT
   '
   B_FT$=_FONTNAME$
   B_FS=_FONTSIZE
   '
   _SETFONT["Topaz",8]
   '
   If T$=""
      T$=T$+"'Amiga Workbench  "+Str$(Chip Free)-" "+" graphics mem  "
      T$=T$+Str$(Fast Free)-" "+" other mem"
   End If 
   _DRAW3DBOX[-1,-1,640,10,T$,1,_SHADOW,_LIGHT]
   '
   _SETFONT[B_FT$,B_FS]
   '
End Proc
'
Procedure _GETBUTTONSTRING[NO]
   '
   Shared _DIALOGBUTTON$
   '
   I1=1
   I2=1
   P=0
   '
   If NO<0
      NO=-NO
   End If 
   '
   While I2<Len(_DIALOGBUTTON$) and P<>NO
      '
      I2=Instr(_DIALOGBUTTON$,";",I1)
      L$=Mid$(_DIALOGBUTTON$,I1,I2-I1)
      '
      BZ=Val(Mid$(L$,19,4))
      If BZ<0
         BZ=-BZ
      End If 
      '
      If BZ=NO
         Exit 
      End If 
      '
      I1=I2+1
      '
      Inc P
   Wend 
   '
End Proc[L$]
'
Procedure _ENABLEBUTTON[NO]
   '
   Shared _DIALOGBUTTON$
   '
   I1=1
   I2=1
   P=0
   '
   While I2<Len(_DIALOGBUTTON$) and P<>NO
      '
      I2=Instr(_DIALOGBUTTON$,";",I1)
      L$=Mid$(_DIALOGBUTTON$,I1,I2-I1)
      '
      BZ=Val(Mid$(L$,19,4))
      If BZ<0
         BZ=-BZ
      End If 
      '
      If BZ=NO
         Mid$(_DIALOGBUTTON$,I1,1)=Upper$(Mid$(_DIALOGBUTTON$,I1,1))
      End If 
      '
      I1=I2+1
      '
      Inc P
   Wend 
   '
End Proc
'
Procedure _DISABLEBUTTON[NO]
   '
   Shared _DIALOGBUTTON$
   '
   I1=1
   I2=1
   P=0
   '
   While I2<Len(_DIALOGBUTTON$) and P<>NO
      '
      I2=Instr(_DIALOGBUTTON$,";",I1)
      L$=Mid$(_DIALOGBUTTON$,I1,I2-I1)
      '
      BZ=Val(Mid$(L$,19,4))
      If BZ<0
         BZ=-BZ
      End If 
      '
      If BZ=NO
         Mid$(_DIALOGBUTTON$,I1,1)=Lower$(Mid$(_DIALOGBUTTON$,I1,1))
      End If 
      '
      I1=I2+1
      '
      Inc P
   Wend 
   '
End Proc
'
Procedure _ADDZONE[X1,Y1,X2,Y2,BZ,TP$]
   '
   Shared _DIALOGBUTTON$
   '
   L$=Space$(22)+Mid$(TP$,2)+";"
   '
   Mid$(L$,1,1)=Mid$(TP$,1,1)
   Mid$(L$,3,3)=Str$(X1)-" "
   Mid$(L$,7,3)=Str$(Y1)-" "
   Mid$(L$,11,3)=Str$(X2)-" "
   Mid$(L$,15,3)=Str$(Y2)-" "
   Mid$(L$,19,4)=Str$(BZ)-" "
   '
   _DIALOGBUTTON$=_DIALOGBUTTON$+L$
   '
End Proc
