Available on: all targets

local task variable operator

To guarantee the use of local variables within parallel procedures, since the procedure does not have a stack, it is necessary to prepare an array to contain this type of information. Therefore, using the array access operator, it is then possible to access the individual variables, using the task identifier as an index.

ugBASIC provides a compact form to indicate this type of access. Instead of writing v(THREAD) you can write [v]. This operator, called the "local task variable operator", can be used anywhere, and in any expression, and can be used as the target of the variable.

In accessing the array, as in any other variable, the dollar sign ($) can be juxtaposed to indicate that you want to access a variable of type string. In this case, a further type check will be carried out during the compilation, to avoid referring to a variable of numerical type.

SYNTAX

 = [variable]
 [variable] = expression
 = [variable$]
 [variable$] = expression


Legend
  • id : identifier
  • type : datatype
  • v : value
  • "..." : string
  • [...] : optional

EXAMPLE

 PUT IMAGE token AT [x],[y]
 [x] = [x] + 1
 PRINT [word$]
 [word$] = "ok!"


Used in:

Any problem?

If you have found a problem with this keyword, if you think there is a bug or, more simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!

open an issue BACK TO KEYWORDS