Skip to content
ChartDeck ChartScript docs Account Open the terminal

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 in const 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

ChartScriptError: CS1054
//@chartscript 1
indicator("Count")
state n = 0
const next = n++ + 1
plot(next)

Fixed

ChartScriptOpen in editor
//@chartscript 1
indicator("Count")
state n = 0
n++
const next = n + 1
plot(next)
  • CS1036 — Only a variable or a field can be assigned to.

The ChartScript documentation is in English for now; translations will follow.