;*************************************************
;* CheckStart Blitz ][ source ) Michael Barkholt *
;*                                               *
;*  Please feel free to alter this for your own  *
;*        use, but don't redistribute!           *
;*                                               *
;*************************************************

AMIGA
FindScreen 0
WBStartup

#RXFB_RESULT =   17
#RXCOMM   =      $01000000            ; a command-level invocation
#RXFF_RESULT =   1LSL#RXFB_RESULT

port.l=CreateMsgPort("Check")                ;Creates Arexx msg port
msg.l=CreateRexxMsg(port,"","Check")
If OpenFile (1,"sys:s/CheckStart.config")    ;Opens the config file
End If
FileInput 1
FileSeek 1,167                               ;Checks the interface option
It$=Edit$(3)

FileSeek 1,212                               ;Checks the first between
bet$=Edit$(4)

FileSeek 1,257
a'nd$=Edit$(4)

FileSeek 1,357
opt$=Edit$(4)

FileSeek 1,398
an'd$=Edit$(4)

FileSeek 1,498
cha$=Edit$(3)

FileSeek 1,590
fil$=Edit$(200)

FileSeek 1,448
dis$=Edit$(3)


If dis$ = "NO"                                ;If disable is off, continue
Gosub check
EndIf

If dis$ = "YES"                               ;If disable is on, end program
End
EndIf

.check

date=SystemDate                               ;checks date

h=Hours
m=Mins

h$=Str$(h)                                    ;Converts time into numbers
m$=Str$(m)

time$=h$+m$

time=Val(time$)

bet=Val(bet$)
a'nd=Val(a'nd$)

opt=Val(opt$)
an'd=Val(an'd$)

If bet <= time AND a'nd >= time               ;Checks if the time is within the first limits
Gosub run
EndIf

If opt <= time AND an'd >= time               ;------||-------
Gosub run
EndIf

Gosub interfaceon

.run

If cha$="YES"
Window 2,0,0,260,11,$8|$1000,"<--press to abandon - you have 3 secs",1,2
gange=0

Repeat
gange=gange+1
                                              ;ARGGH....this is boring...jeg gider ikke kommentere flere linier!!
If gange =>5
CloseWindow 2
Gosub vid
EndIf

VWait 50

  y.l=Event
    Select y
      Case $200
        CloseWindow 2
        Gosub interfaceon
    End Select
Forever
EndIf

.vid

SendRexxCommand msg,"SYS:s/CheckStart.config",#RXCOMM|#RXFF_RESULT

VWait 200

Gosub interfaceon

.interfaceon
If It$ = "ON"
Gosub Interface
EndIf

If It$ = "OFF"
End
EndIf

.Interface
LoadFont 1,"XEN.font",8
GTButton 1,1,5,5,20,11,"Launch current script",2
GTString 1,2,55,20,40,12,"Between",1,4
GTString 1,3,130,20,40,12,"and",1,4
GTString 1,4,55,50,40,12,"Between",1,4
GTString 1,5,130,50,40,12,"and",1,4
GTString 1,6,5,80,150,12,"",1,200
GTButton 1,7,155,80,17,12,"CD",$10
GTButton 1,8,135,105,30,12,"Save",$10
GTButton 1,9,135,120,30,12,"Quit",$10
GTCheckBox 1,10,5,110,10,12,"Last chance?",2
GTCheckBox 1,11,5,95,10,12,"Interface?",2|$100
GTCheckBox 1,12,5,125,10,12,"Disable?",2

Window 0,0,11,180,150,$2|$8|$1000|$4,"CheckStart interface",1,2
WindowFont 1
WLocate 44,37
Print "And optionaly:"
WLocate 35,67
Print "Script to execute:"
AttachGTList 1,0
WLocate 0,0

.strings

GTSetString 1,2,bet$
GTSetString 1,3,a'nd$
GTSetString 1,4,opt$
GTSetString 1,5,an'd$

.fil
GTSetString 1,6,fil$


.loop

Repeat
  e.l=WaitEvent
    Select e
      Case $40
        g=GadgetHit
        If g=9 Then End
        If g=7 Then Gosub cd
        If g=8 Then Gosub save
        If g=1 Then Gosub launch
      Case $200
        End
    End Select
Forever

.cd

MaxLen p$=192
MaxLen f$=192

fil$=ASLFileRequest$("Choose script",p$,f$,"#?")

Gosub fil

.save

bet$=GTGetString(1,2)
a'nd$=GTGetString(1,3)
opt$=GTGetString(1,4)
an'd$=GTGetString(1,5)
fil$=GTGetString(1,6)

s=GTStatus (1,10)
f=GTStatus (1,11)

FileOutput 1

If f=1 Then f$="ON "
If f=0 Then f$="OFF"

FileSeek 1,167
Print f$

FileSeek 1,212
Print bet$

FileSeek 1,257
Print a'nd$

FileSeek 1,357
Print opt$

FileSeek 1,398
Print an'd$

If s=1 Then l$="YES"
If s=0 Then l$="NO "

FileSeek 1,498
Print l$

fil$="'"+fil$+"'"

FileSeek 1,590
Print fil$

;FileSeek 1,448
;dis$=Edit$(3)

Gosub loop


.launch
SendRexxCommand msg,"SYS:s/CheckStart.config",#RXCOMM|#RXFF_RESULT

VWait 200

Gosub loop


