Gosub.htm 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <html>
  2. <head>
  3. <title>Blitz3D Docs</title>
  4. <link rel=stylesheet href=../css/commands.css type=text/css>
  5. </head>
  6. <body>
  7. <h1>Gosub label</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. label = any valid exisiting label
  13. </td>
  14. </tr>
  15. </table>
  16. <h1>Description</h1>
  17. <table>
  18. <tr>
  19. <td>
  20. This branches the flow of the program to a designated label, with the understanding that there will be a Return later on in the called code to resume execution of the program where the Gosub was called. With the use of Functions inside of Blitz, it isn't very practical to use Gosubs, but you may still find it useful. If you do not require the need to return execution back to the Gosub statement, you may use Goto instead. See the example.
  21. <br>
  22. <br>
  23. See also: <a class=small href=Return.htm>Return</a>, <a class=small href=Goto.htm>Goto</a>, <a class=small href=Function.htm>Function</a>.
  24. </td>
  25. </tr>
  26. </table>
  27. <h1><a href=../2d_examples/Gosub.bb>Example</a></h1>
  28. <table>
  29. <tr>
  30. <td>
  31. Print "The program starts ..." <br />
  32. Gosub label1 <br />
  33. Print "The Program ends ..." <br />
  34. <br />
  35. ; wait for ESC key before ending <br />
  36. While Not KeyHit(1) <br />
  37. Wend <br />
  38. <br />
  39. End <br />
  40. <br />
  41. .label1 <br />
  42. Print "We could do all sorts of things in this part of the program..." <br />
  43. Print "But, we'll just go back to the original code, instead ..." <br />
  44. Return
  45. </td>
  46. </tr>
  47. </table>
  48. <br>
  49. <a target=_top href=../index.htm>Index</a><br>
  50. <br>
  51. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=Gosub&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  52. </html>