Variables not working in View(R3)
I'm quite confused. In theory having a counting variable is very straightforward... c: c + 1 However, I've found that when I do this within a view it doesn't work... I put together a test program to demonstrate: R E B O L [Title: "Variable Experiment"] load-gui cnt: 0 alert to-string cnt view layout [ cnt: cnt + 1 alert to-string cnt ] The first alert successfully states that cnt is equal to zero. Then I get an error: ** GUI ERROR: Cannot parse the GUI dialect at: cnt + 1 alert to-string To me, this error means that it's trying to parse the cnt + 1 as part of the GUI dialect, and so naturally it doesn't work... But... if I have a button or drop-down or anything, and put this code into the on-action block it still doesn't work. For example: cnt: 0 view/no-wait layout[ btnColorless1: image elColorless ; --elColorless refers to a .png file on-action[ cnt: cnt + 1 ] ] This specific example actually yields the following error: ** Syntax error: missing "[" at "end-of-block" ** Where: to case load either either -apply- ** Near: (line 27) ] In my actual project however I'm getting this error: ** Script error: cannot use add on none! value ** Where: + actor all foreach do-actor unless do-face if actor all foreach do-actor if do-event do-event if do-event either -apply-wake-up loop -apply-wait forever try do-events do either either either -apply- ** Near + 1 setpos (setpos is the name of a function I defined) What I need to do ultimately is count how many times a button has been clicked. But I really can't understand what's wrong, and how to make it work... Please help :)
posted by: mothdragon 25-Aug-2014/20:32:32-7:00
The other way to fix this from my other answer is to use a function that you define outside the action block. R E B O L [] cnt: 0 count: funct/extern [][ ++ cnt ][ cnt ] view [ button "Count presses" on-action [ count ] ]
posted by: Graham 25-Aug-2014/21:44:57-7:00
Thanks Graham. :) Sorry for the double post. The page crashed last time I tried to post this question. I didn't realize it had posted.
posted by: mothdragon 26-Aug-2014/6:46:25-7:00
|