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 :)