| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <html>
- <head>
- <title>Blitz3D Docs</title>
- <link rel=stylesheet href=../css/commands.css type=text/css>
- </head>
- <body>
- <h1>Select variable</h1>
- <h1>Parameters</h1>
- <table>
- <tr>
- <td>
- variable - any valid variable
- </td>
- </tr>
- </table>
- <h1>Description</h1>
- <table>
- <tr>
- <td>
- 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 />
-
<br />
-
<br />
- This selection structure removes the need for large nested IF/THEN condition checking. See the example for more.
- <br>
- <br>
- 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>.
- </td>
- </tr>
- </table>
- <h1><a href=../2d_examples/Select.bb>Example</a></h1>
- <table>
- <tr>
- <td>
- ; SELECT/CASE/DEFAULT/END SELECT Example
<br />
-
<br />
- ; Assign a random number 1-10
<br />
- mission=Rnd(1,10)
<br />
-
<br />
- ; Start the selection process based on the value of 'mission' variable
<br />
- Select mission
<br />
-
<br />
- ; Is mission = 1?
<br />
- Case 1
<br />
- Print "Your mission is to get the plutonium and get out alive!"
<br />
-
<br />
- ; Is mission = 2?
<br />
- Case 2
<br />
- Print "Your mission is to destroy all enemies!"
<br />
-
<br />
- ; Is mission = 3?
<br />
- Case 3
<br />
- Print "Your mission is to steal the enemy building plans!"
<br />
-
<br />
- ; What do do if none of the cases match the value of mission
<br />
- Default
<br />
- Print "Missions 4-10 are not available yet!"
<br />
-
<br />
- ; End the selection process
<br />
- End Select
- </td>
- </tr>
- </table>
- <br>
- <a target=_top href=../index.htm>Index</a><br>
- <br>
- 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>
- </html>
|