I've found a strange thing, concerning the organization of “while” loops in HScript. The strange thing is that a code of the following type:
set somevar = 0
while($somevar < 1)
set somevar = 1
end
loops. I've tried opening a copy of the code in Houdini's Textport window and running it. The result was as it had been predicted - the loop ran only once.
At last I came to a conclusion that you must put a space after “while” and an opening bracket, between the opening bracket and a condition, between the condition and the closing bracket, i.e.
while ( $somevar < 1 )
In this case the code runs as it should.
Bug: Hscript "while" loop structure
4011 4 1- hoknamahn
- Member
- 398 posts
- Joined: July 2005
- Offline
- EigenAlex
- Member
- 639 posts
- Joined: July 2005
- Offline
- madjestic
- Member
- 325 posts
- Joined: July 2005
- Offline
What Hoknamahn says is this -
let's consider the first case (code example #1) -
a) How the code is supposed to work:
set somevar = 0…………//somevar = 0
while($somevar < 1)…….//somevar = 0, i.e. somevar<1, the loop starts
set somevar = 1…………//somevar ==1, th loop starts once more,
end ………… //check whether somevar is less than 1,
………… //but because it is 1 already - the loop breaks.
b) In the textport this code runs O.K.
c) Being loaded into HScript the loop runs endlessly and halts the OS.
d) The only way Hoknamahn succeded in running the code in HScript was that he modified his code (syntax) with extra ‘ ’ (spaces) after the opening bracket, before and such.
let's consider the first case (code example #1) -
a) How the code is supposed to work:
set somevar = 0…………//somevar = 0
while($somevar < 1)…….//somevar = 0, i.e. somevar<1, the loop starts
set somevar = 1…………//somevar ==1, th loop starts once more,
end ………… //check whether somevar is less than 1,
………… //but because it is 1 already - the loop breaks.
b) In the textport this code runs O.K.
c) Being loaded into HScript the loop runs endlessly and halts the OS.
d) The only way Hoknamahn succeded in running the code in HScript was that he modified his code (syntax) with extra ‘ ’ (spaces) after the opening bracket, before and such.
I liked the Mustang
- hoknamahn
- Member
- 398 posts
- Joined: July 2005
- Offline
In this very case it doesn't matter, whether we've got “set somevar = 1” or “set somevar = `$somevar + 1`” - in this case I took the most simple loop checking condition. The problem is that in certain situations (this is a mistery for me) the loop runs as it should, in other cases it runs endlessly (hey, SESI?) and the only way to bypass this drawback is to put additional spaces - as I've shown above.
f = conserve . diffuse . advect . add
fx td @ the mill
fx td @ the mill
- jrwillette
- Member
- 49 posts
- Joined: July 2005
- Offline
I duplicated your code, no spaces, and ran it in both Hscript and in Houdini's textport and it ran just fine both ways. I know you said it isn't always consistant so it may be difficult to figure out.
Questions/Things to look at:
Are you on Windows or Linux? I ran my test on windows ops:
What text editor are you using? Perhaps there are hidden characters in your code? Try writing it with different editors.
How are you running the script? source myscript.cmd?
If you want, zip/gzip an example that isn't working and mail it to me jeff@mister2.net and I'll take a look and see if I have the same problem.
It's important to zip it up so the email process doesn't mess with the file.
Questions/Things to look at:
Are you on Windows or Linux? I ran my test on windows ops:
What text editor are you using? Perhaps there are hidden characters in your code? Try writing it with different editors.
How are you running the script? source myscript.cmd?
If you want, zip/gzip an example that isn't working and mail it to me jeff@mister2.net and I'll take a look and see if I have the same problem.
It's important to zip it up so the email process doesn't mess with the file.
Jeff Willette
Freelance TD
Freelance TD
-
- Quick Links