Task

Write a procedure which accepts as arguments another procedure and a positive integer.

The latter procedure is executed a number of times equal to the accepted integer.




DEFINE PTR="CARD"
 
PROC OutputText(CHAR ARRAY s)
  PrintE(s)
RETURN
 
PROC Procedure=*(CHAR ARRAY s)
  DEFINE JSR="$20"
  DEFINE RTS="$60"
  [JSR $00 $00 ;JSR to address set by SetProcedure
   RTS]
 
PROC SetProcedure(PTR p)
  PTR addr
 
  addr=Procedure+1 ;location of address of JSR
  PokeC(addr,p)
RETURN
 
PROC Repeat(PTR procFun CHAR ARRAY s BYTE n)
  BYTE i
 
  SetProcedure(procFun)
  FOR i=1 TO n
  DO
    Procedure(s)
  OD
RETURN
 
PROC Main()
  Repeat(OutputText,"Action!",5)
RETURN