CS1054
error ++ and -- work only as a statement of their own (i++), not inside an expression.
#What it means
x++ and x-- add or subtract 1 and are statements of their own. ChartScript does not allow them inside a larger expression, where the order of "read" and "change" is easy to get wrong.
#Typical cause
i++used inside a calculation, a call or a condition, as inconst j = i++ + 1.
#How to fix it
Put i++ on its own line, before or after the line that uses the value. See Operators.
#Example
//@chartscript 1
indicator("Count")
state n = 0
const next = n++ + 1
plot(next)Fixed
//@chartscript 1
indicator("Count")
state n = 0
n++
const next = n + 1
plot(next)#Related
- CS1036 — Only a variable or a field can be assigned to.