'----------------------------------------------------------------------------
'
' AMOS Procedure Locker, by Francois Lionet. AMOS 1.2 and over ONLY! 
'
'----------------------------------------------------------------------------
'
' To operate:
'
' First load this program as an accessory. 
' Load your program into the editor
' Call this program (the loaded accessory).
' It will lock all CLOSED procedures. They will be forever LOCKED! So be very
' careful. Have a backup of the original.  
'
' AMOS 1.1 users: do NOT open a locked procedure! It will crash the computer!
'  
' PS: Yes, of course, the procedure that locks the procedures is locked  
' by itself. Wicked izn't it?!?    
'----------------------------------------------------------------------------
'
Default Palette 0,0,$FFF,0
Screen Open 7,640,72,4,Hires : Curs Off 
Screen Display 7,,100,,
Centre At(,2)+Border$("   AMOS Procedures locker   ",1)
Locate 0,5
'
If Areg(3)=0
   Centre "Sorry! I only work with AMOS 1.2 and over!"
   BYEBYE
End If 
'
If Dreg(0)=0
   Centre "You must call me as an accessory!"
   BYEBYE
End If 
'
LOCKIT
BYEBYE
'
Procedure LOCKIT
   AD=Areg(3)
   TKPROC=$376
   Do 
      L=Peek(AD)*2
      Exit If L=0
      If Deek(AD+2)=TKPROC
         P=Deek(AD+10)
         If Btst(15,P)
            Bset 14,P
            P=(P and $FF00)+Rnd(254)+1
            Doke AD+10,P
            Inc TT
         End If 
      End If 
      AD=AD+L
   Loop 
   If TT
      A$="I have locked"+Str$(TT)+" procedure"
      If TT>1 : A$=A$+"s" : End If 
      A$=A$+"."
   Else 
      A$="No procedures to lock!"
   End If 
   Centre A$
End Proc
Procedure BYEBYE
   Print : Print 
   Centre "Press any key"
   Wait Key : Screen Close 7 : Edit 
End Proc