On

Last Modified: 1/4/2021

Sets the line label of code to run during an Interrupt.

Arguments

NameTypeRequiredDescription
Interrupt System Identifier Yes The type of Interrupt you are setting up.
Label Line Label Yes The label where the code you wish to execute during the Interrupt.

Interrupt Types

TypeDescription
ExtInt, InterruptExtInt Sets the routine for the external interrupt.
HBlank, hInt, InterruptHBlank Sets the routine for the horizontal interrupt.
InterruptVBlank, VBlank, vInt Sets the routine for the vertical interrupt.

Example

Syntax: On <Interrupt> Gosub <Label>
    On vInt GoSuB MyVblank
    Enable vInt
    
    While 1
        Locate 1,1
        Print b
        Sleep 1
    Wend
    
    MyVblank:
    a++
    If a = 60 Then
        b++
        a = 0
    End If
    Return

Remarks

The code found at Label needs to have a Return command at the end.

The vertical interrupt executes 60 times per second on NTSC systems, and 50 times on PAL. The horizontal interrupt is significantly shorter in time, and is generally used for raster effects.

Due to the horizontal interrupt wrapper in the BASIC library, very few rasters can actually be done in SecondBASIC Studio.

See Also

Disable, Enable, GoSub, HBlank, Return