Expected while?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Expected while?

Mikey2520

What is this, I got while, "(" and "{", but it's still saying it's wrong..
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Expected while?

ivant
You're probably missing a close parentheses of some sort before this line.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Expected while?

ybakos
In reply to this post by Mikey2520
I could be mistaken but I believe you'll need to group the terms in that boolean expression, eg:

while ((a~=dx) | (b ~= dy)) {

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Expected while?

cadet1620
Administrator
In reply to this post by Mikey2520
"~=" is not a valid token in Jack. (There are no two character tokens except // /* and */.)

You need to code "not equals" as ~(a=dx).

Also, remember that there is no defined order of operation, so you need to fully parenthesize complex expressions.
    while ( (~(a=dx)) | (~(b=dx)) )
Whitespace can really aid readability of Jack expressions!

--Mark
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Expected while?

ybakos
Ah, that was it. Clearly I need a refresher!
Loading...