OK, we’ve approached the end of learning new commands, now we’ll actually focus on creating great programs with them. In this post, we’ll cover using trapped boxes with the goto, end, and if-then commands. In this program, we have a trap box:
10 print “Is it a snow day?”
20 input y
30 if y==”yes” then goto 60
40 print “Aww… You’re so academically energized…”
60 print “Yeah! Let’s celebrate!”
As you see, 30-50 is actually seperated from the rest of the program, creating the trap box. Normally, the program would continue from 10 to 70, but the end statement at 50 means that the trap box is there, so if you answer anything other than yes, it will not print #60 and go on, but simply ending the whole program when you say no.
Similarly, if you answer yes to this program, you will skip to 60 and print #60, skipping the first trap box and referring to the second one.
Why Do We Do It In This Way?
Unlike HTML and other programming languages, BASIC is, well, basic, and doesn’t allow cross-referring programs like HTML, using the <a href command. Trap boxes can be used as much as possible, and are easier to import and export than thousands of programs.
A Strong Note
Thanks for coping with me. That’s it. Just comment or contact if you have any programs.