deepak
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2013
02:11 PM
The "next" keyword
I thought that the next keyword was the BrightScript equivalent for, say, Java's continue. But, it turns out that it is equivalent to end for. Why ?
1. Every keyword K, which begins its own scope - function sub, if, while, for - ends with end K. Why an additional synonym for end for ?
2. Does this also mean BrightScript doesn't have anything equivalent for Java's continue ? Like exit for is the equivalent to Java's break ?
1. Every keyword K, which begins its own scope - function sub, if, while, for - ends with end K. Why an additional synonym for end for ?
2. Does this also mean BrightScript doesn't have anything equivalent for Java's continue ? Like exit for is the equivalent to Java's break ?
1 REPLY 1

RokuJoel
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2013
03:14 PM
Re: The "next" keyword
Brightscript is more similar to BASIC, where For is always followed by a Next:
(notice, you don't reference the variable name in a for each)
However Next is deprecated in favor of End For
There is no continue. There is a goto statement which can jump to labeled code:
Generally, using goto statements is not recommended.
- Joel
for i=0 to 100
print i
next i
for each element in array
?element
next
(notice, you don't reference the variable name in a for each)
However Next is deprecated in favor of End For
for i=0 to 100
print i
end for
for each element in array
print element
end for
There is no continue. There is a goto statement which can jump to labeled code:
sub main()
for i=0 to 100
if i=50 then
goto somewhere
end if
end for
somewhere:
print "i=";i
end sub
Generally, using goto statements is not recommended.
- Joel