User Tools

Site Tools


ugbasic:user:kw:local_task_variable_operator
Translations of this page:


ugBASIC User Manual

local task variable operator ✓

SYNTAX

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

PURPOSE

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.

EXAMPLE

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

See also the following example files:

AVAILABLE ON

  • Atari (400/800)
  • Atari XL/XE
  • Commodore 128 (MOS 8502)
  • Commodore 128 (Zilog Z80)
  • Commodore 64
  • TRS-80 Color Computer
  • TRS-80 Color Computer 3
  • ColecoVision
  • Amstrad CPC 664
  • Dragon 32
  • Dragon 64
  • Thomson MO5
  • Thomson MO5
  • Olivetti Prodest PC128
  • Commodore PLUS/4
  • SEGA SC-3000
  • SEGA SG-1000
  • VG-5000
  • Commodore VIC-20
  • ZX Spectrum 48

ANY PROBLEM?

If you have encountered a problem using this command, if you think there is a bug or the explanation is unclear, please open an issue for this keyword on GitHub. Thank you!

POWERED BY