Parenthesis: Difference between revisions
Jump to navigation
Jump to search
Created page with "'''Parenthesis''' are used to enclose SUB and FUNCTION parameters or to set the operation order in Mathematical Operations. ''Usage:'' COLOR 14: PRINT TAB(30); "Hello World" {{OutputStart}} {{text|Hello World|yellow}} {{OutputEnd}} * SUB parameters MUST be enclosed in parenthesis when the CALL statement is used. Do '''not''' use parenthesis without CALL. * Parenthesis can be used in calculations to determine the..." |
No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
{{OutputStart}} | {{OutputStart}} | ||
{{ | {{Text|Hello World|yellow}} | ||
{{OutputEnd}} | {{OutputEnd}} | ||
Line 17: | Line 17: | ||
''Example:'' Using too many brackets does not harm the code execution as long as they are paired up. | ''Example:'' Using too many brackets does not harm the code execution as long as they are paired up. | ||
{{CodeStart}} | {{CodeStart}} | ||
nmb$ = {{Cl|STR$}}(100) | nmb$ = {{Cl|STR$}}(100) | ||
nmb$ = {{Cl|LTRIM$}}((({{Cl|RTRIM$}}(nmb$)))) 'extra bracket pairs do not affect the code | nmb$ = {{Cl|LTRIM$}}((({{Cl|RTRIM$}}(nmb$)))) 'extra bracket pairs do not affect the code | ||
{{Cl|PRINT}} nmb$ | {{Cl|PRINT}} nmb$ | ||
{{CodeEnd}} | {{CodeEnd}} | ||
{{PageSeeAlso}} | |||
* [[DIM]] | |||
* [[DIM]] | |||
* [[SUB]], [[FUNCTION]] | * [[SUB]], [[FUNCTION]] | ||
* [[Arrays]] | * [[Arrays]] |
Latest revision as of 22:44, 11 February 2023
Parenthesis are used to enclose SUB and FUNCTION parameters or to set the operation order in Mathematical Operations.
Usage: COLOR 14: PRINT TAB(30); "Hello World"
Hello World
|
- SUB parameters MUST be enclosed in parenthesis when the CALL statement is used. Do not use parenthesis without CALL.
- Parenthesis can be used in calculations to determine the order in which math operations are performed when the normal order would not work correctly. Normal operation order is: 1) exponential, 2) multiplication or division 3) addition or subtraction.
- Parenthesis can also denote the array index or the dimension size(s) in a DIM statement.
- Instead of BYVAL, use extra parenthesis around sub-procedure call parameters to pass them by value instead of by reference.
- Extra pairs of brackets have no effect on the code! If one is missing the IDE should tell you.
Example: Using too many brackets does not harm the code execution as long as they are paired up.
nmb$ = STR$(100) nmb$ = LTRIM$(((RTRIM$(nmb$)))) 'extra bracket pairs do not affect the code PRINT nmb$ |
See also