Tuesday, July 2, 2013

Tutorial 2 - Labels and Subroutines

Today we will be going over labels and subroutines.
A label is simply a place in your code that can be jumped to on command, while a subroutine is basically a label that will perform a set of actions and return you to where you were in your code. I will assume you have read our first tutorial or know how to start coding and run your programs. Lets get to it.


  1. 'Comments can be written starting with ', everything after it is ignored.
  2. VISABLE 1,0,0,0,0,0:ACLS:CLS   'Multiple commands can be separated with :
  3. GOTO @OURLABEL
  4. PRINT "THIS CODE WILL NOT BE EXECUTED"
  5. @OURLABEL
  6. PRINT "WE JUST JUMPED TO OUR LABEL!"
  7. GOSUB @OURSUBROUTINE
  8. PRINT "THIS CODE WILL BE EXECUTED"
  9. END
  10. @OURSUBROUTINE
  11. PRINT "WE ENTERED THE SUBROUTINE!"
  12. RETURN



New Commands Used:
GOTO - Forced Branch.
This command jumps to a label and executes the code after it.

  • GOTO @label
GOSUB - Call sub-routine.
This command jumps to a label and can be returned back to its original position in code.

  • GOSUB @label
RETURN - Returns from a sub-routine.
This will return you to where you called GOSUB.

  • RETURN
END - Ends the program.
This quits out of the program.

  • END

QR Code for this Tutorial



2 comments:

  1. A label is simply a place in your code that can be jumped to on command, while a subroutine is basically a label that will perform urdu video tutorial sites

    ReplyDelete
  2. tutorial or know how to start coding and run your programs. Lets get to it.wordpress tutorial in urdu

    ReplyDelete