So I have a plotscript which calls upon another script within it. Nothing wrong with that. The problem is that this script is called within a for loop of the plotscript, thus when I use the function "continue" within the script it's giving me the following error:
"Continue used outside of do() script will be exited"
Technically the "continue" function is within the do() because the do() is calling on a separate script.
Is there a way to fix this?
I figure I could combine the script into my plotscript rather than calling it separately. This would be bothersome though since it would make the plotscript ginormous....
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Not quite, mine is a plotscript which calls upon a script like this:
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Code:
plotscript, first, begin
for(x, 0, 10) do,begin
second
end
end
script, second, begin
# do stuff
if(condition) then(continue)
# do more stuff
end
plotscript, first, begin
for(x, 0, 10) do,begin
second
end
end
script, second, begin
# do stuff
if(condition) then(continue)
# do more stuff
end
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
There's a couple of things you could do here. The main thing is to get the continue command into the first script. You could do it like this:
If it's feasible, you could also split the second script into two separate scripts.
Code:
plotscript, first, begin
for(x, 0, 10) do,begin
if(second == -1) then(continue)
end
end
script, second, begin
# do stuff
if(condition) then(exit returning(-1))
# do more stuff
return(0)
end
for(x, 0, 10) do,begin
if(second == -1) then(continue)
end
end
script, second, begin
# do stuff
if(condition) then(exit returning(-1))
# do more stuff
return(0)
end
If it's feasible, you could also split the second script into two separate scripts.
Code:
plotscript, first, begin
for(x, 0, 10) do,begin
second
if(condition) then(continue)
third
end
end
script, second, begin
# do stuff
end
script, third, begin
# do more stuff
end
for(x, 0, 10) do,begin
second
if(condition) then(continue)
third
end
end
script, second, begin
# do stuff
end
script, third, begin
# do more stuff
end
I see. Well perhaps I may just have to combine it in to one big script because my second script has about 20 "continue" functions in series which raises the difficulty of solving it any of these ways. It's okay though, I've attempted to make one big plotscript and it works. Hopefully having a giant plotscript doesn't lead me to any struggles later though.
Out of curiosity why can't the "continue" be called like I have described? If you know...
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Out of curiosity why can't the "continue" be called like I have described? If you know...
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
You can use the 'exit returning' technique Sephy gave regardless of the number of continue statements in the script; no need to inline it.
'continue' and 'break' can't jump across script boundaries because HamsterSpeak is a lexically scoped language, just like most other modern programming languages. That means that the compiler or a human can tell what a script does without looking at any other scripts. Under the alternative, dynamic scoping, a "continue" would behave like an exception, and you can't tell where it's going to jump to.
'continue' and 'break' can't jump across script boundaries because HamsterSpeak is a lexically scoped language, just like most other modern programming languages. That means that the compiler or a human can tell what a script does without looking at any other scripts. Under the alternative, dynamic scoping, a "continue" would behave like an exception, and you can't tell where it's going to jump to.
Alright good to know. I guess I don't program much outside of this language so I've never run in to this kind of thing before.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases



