Jump anywhere: Difference between revisions
Content added Content deleted
(Added VTL-2) |
|||
Line 2,877: | Line 2,877: | ||
=={{header|VBScript}}== |
=={{header|VBScript}}== |
||
In VBScript, there is no <code>goto</code> statement. It is a good thing for structured programming. |
In VBScript, there is no <code>goto</code> statement. It is a good thing for structured programming. |
||
=={{header|VTL-2}}== |
|||
VTL-2 doesn't do structured programming as such - the only control structure is the <code>goto</code>.<br> |
|||
In VTL2, everything is an assignment - including gotos - which are effected by assigning to the system variable <code>#</code>.<br> |
|||
The assigned value can be any valid expression - it need not be a constant.<br> |
|||
If the expression evaluates to 0, the next statement is executed (or the program stops if there is no next statement).<br> |
|||
If the expression evaluates to a line number present in the program, the program continues from that statement.<br> |
|||
If the expression does not evaluate to a line number present in the program, the program continues with the next highest line number or stops if there is no line with a number higher that the expression.<br> |
|||
The following program demonstrates this - prompiting the user for a label to goto. (In an expression, <code>?</code> indicates a value should be read from the console, assigning to <code>?</code> prints the assigned value)<br> |
|||
<lang VTL2>1010 ?="@1010: Where to goto? "; |
|||
1020 #=? |
|||
1030 ?="@1030" |
|||
1040 #=1010 |
|||
1050 ?="@1050" |
|||
1060 #=1010 |
|||
2000 ?="@2000" |
|||
2010 ?="Exiting..."</lang> |
|||
{{out}} |
|||
<pre> |
|||
@1010: Where to goto? 0 |
|||
@1030 |
|||
@1010: Where to goto? 1030 |
|||
@1030 |
|||
@1010: Where to goto? 1041 |
|||
@1050 |
|||
@1010: Where to goto? 1000+50 |
|||
@1050 |
|||
@1010: Where to goto? 9999 |
|||
</pre> |
|||
=={{header|Wren}}== |
=={{header|Wren}}== |