DEFINT a-z

	IF argcount<>1 THEN
           ?:?:?"      BOOTUP v0.0a by Krisztian R. Hildebrand, HA5XA":?:?
           PRINT"      Usage:  BOOTUP x     ( x = 1 to 999 )":?
	   PRINT"      where x is the number of seconds the program waits"
 	   PRINT"      before executing the default script.":?:?
  	   STOP
	END IF

timeleft=val(arg$(1))
	IF timeleft<=0 or timeleft>999 THEN
           ?:?:?"BOOTUP v0.0a by Krisztian R. Hildebrand, HA5XA":?:?
   	   PRINT "Incorrect argument." 
	   PRINT "BOOTUP x    ( x = 1 to 999 )"
   	   STOP
	END IF

ON GADGET GOSUB REQHANDLER
ON TIMER (1) GOSUB TIMEHANDLER

printed$="                            BOOTUP v0.0a by Krisztian R. Hildebrand, HA5XA, 1995. "
printed$=printed$+"This program is written in ACE, the best Freeware BASIC compiler around, "
printed$=printed$+"thank you, David.  --- See the DOC file for more details about this program"
printed$=printed$+" and to find out how to contact the author... ---  "

GOSUB REQSETUP

MAIN:
    TIMER ON
    GADGET ON
    GOSUB LSCROLLING
    WHILE 1
      SLEEP
      GOSUB LSCROLLING
      IF executed=1 or skip=1 THEN
         GOSUB REQCLEANUP
         TIMER OFF
      	 GADGET OFF
      	 SYSTEM 0
      END IF
    WEND
END



TIMEHANDLER:
  --timeleft
  PENUP:SETXY 122,43
  PRINTS "    "
  IF timeleft>0 AND executed<>0 THEN
    PENUP:SETXY 122,43
    CASE
     timeleft<10 : prints space$(2);
     timeleft>9 and timeleft<=99: prints space$(1);
     timeleft>99 : print "";
    END CASE
    PRINTS timeleft
  END IF
  IF timeleft<0 and executed<>1 THEN gosub execution
RETURN



EXECUTION:
       IF executed<>1 then
          SYSTEM "execute s:Bootup.commands"
          executed=1
       END IF
RETURN


SKIPPING:
   skip=1
RETURN


REQHANDLER:
  theGadget = GADGET(1)
  CASE
    theGadget=254 : GOSUB execution
    theGadget=255 : GOSUB skipping
  END CASE
RETURN

  
REQSETUP:
   WINDOW 9,,(170,50)-(470,175),0
   GADGET 255,ON,"SKIP EXECUTION",(17,83)-(272,107),BUTTON
   GADGET 254,ON,"EXECUTE COMMANDS",(17,53)-(274,78),BUTTON
   BEVELBOX (21,10)-(270,26),2
   BEVELBOX (6,3)-(284,116),2
   BEVELBOX (120,30)-(170,49),2
RETURN


REQCLEANUP:
    FOR n=255 TO 254 STEP -1
        GADGET CLOSE n
    NEXT
    WINDOW CLOSE 9 
RETURN


LSCROLLING:
 	printed$=mid$(printed$,2,30)+mid$(printed$,32,len(printed$)-31)+left$(printed$,1)
 	PENUP:SETXY 26,20
 	PRINTS left$(printed$,30)  
RETURN