random_gosub.pai

< Prev | Back | Next >


function option_1
    print "This is the first function!"
end

function option_2
    print "Here is the second!"
end

function option_3
    print "And I am the third one!"
end

function ignored
    print "This function will NEVER get called"
end

#Choose a random function to jump to
#Note how dynamic `call` MUST be in an if statement; the jump might fail if `number` is some other value.
let number = {random_int(1, 3)}
if call "option_{number}" then
    print "Success"
else
    print "Function does not exist"
end

< Prev | Back | Next >