Select.htm 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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>Select variable</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. variable - any valid variable
  13. </td>
  14. </tr>
  15. </table>
  16. <h1>Description</h1>
  17. <table>
  18. <tr>
  19. <td>
  20. This command allows you to set up a selection structure that, based on the value of the variable you feed it, will execute different commands in different CASEs. You can also specify a DEFAULT set of commands to happen if NONE of the CASEs are met. The selection structure is ended with an END SELECT command. <br />
  21. <br />
  22. <br />
  23. This selection structure removes the need for large nested IF/THEN condition checking. See the example for more.
  24. <br>
  25. <br>
  26. See also: <a class=small href=Case.htm>Case</a>, <a class=small href=Default.htm>Default</a>, <a class=small href=True.htm>True</a>, <a class=small href=False.htm>False</a>, <a class=small href=If.htm>If</a>.
  27. </td>
  28. </tr>
  29. </table>
  30. <h1><a href=../2d_examples/Select.bb>Example</a></h1>
  31. <table>
  32. <tr>
  33. <td>
  34. ; SELECT/CASE/DEFAULT/END SELECT Example <br />
  35. <br />
  36. ; Assign a random number 1-10 <br />
  37. mission=Rnd(1,10) <br />
  38. <br />
  39. ; Start the selection process based on the value of 'mission' variable <br />
  40. Select mission <br />
  41. <br />
  42. ; Is mission = 1? <br />
  43. Case 1 <br />
  44. Print "Your mission is to get the plutonium and get out alive!" <br />
  45. <br />
  46. ; Is mission = 2? <br />
  47. Case 2 <br />
  48. Print "Your mission is to destroy all enemies!" <br />
  49. <br />
  50. ; Is mission = 3? <br />
  51. Case 3 <br />
  52. Print "Your mission is to steal the enemy building plans!" <br />
  53. <br />
  54. ; What do do if none of the cases match the value of mission <br />
  55. Default <br />
  56. Print "Missions 4-10 are not available yet!" <br />
  57. <br />
  58. ; End the selection process <br />
  59. End Select
  60. </td>
  61. </tr>
  62. </table>
  63. <br>
  64. <a target=_top href=../index.htm>Index</a><br>
  65. <br>
  66. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=Select&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  67. </html>