4 ms·
A more useful example I found: REPEAT ... UNTIL CtrlC() OR (IF m:=GetMsg(wnd.userport) THEN ReplyMsg(m) BUT 1 ELSE 0) Which means loop until Ctrl-C
by amiga386 1y ago
A more useful example I found:
REPEAT
...
UNTIL CtrlC() OR (IF m:=GetMsg(wnd.userport) THEN ReplyMsg(m) BUT 1 ELSE 0)
Which means loop until Ctrl-C is pressed, or an IDCMP message comes to the window (which must be replied to allow the sender to reuse/free the message, but otherwise we don't care what's in the message, because we know it's either a keypress or a mouseclick, and both end the loop).
The comma operator, or "BUT", lets us capture the result of GetMsg(), go down a positive "we got a message so end the loop" path, but also fits in a ReplyMsg() so we don't have to deal with it anywhere else
- tialaramex 1y agoLike I said though, you wanted an expression language, just have an expression language loop { // ... if ctrl_c() || match get_msg(wnd.userport) { None => false, Some(m) => { _ = reply_msg(m); true } } { break; } }