{{htmlmetatags>metatag-robots=() metatag-title=(array operator | ugBASIC User Manual) metatag-keywords=(ugBASIC,Commodore 64,Commodore PLUS/4,ZX Spectrum) metatag-description=(Manual page for array operator) metatag-media-og:image=(:ugbasic:logo-ugbasic-fb.png) metatag-og:title=(array operator | ugBASIC User Manual) metatag-og:description=(Manual page for array operator) }} ====== ugBASIC User Manual ====== ===== array operator ===== ===== SYNTAX ===== ... = var( o1 [, i2 [, ...] ] ) var( o1 [, i2 [, ...] ] ) = expr ... = var$( o1 [, i2 [, ...] ] ) var$( o1 [, i2 [, ...] ] ) = expr$ ==== PURPOSE ==== In ugBASIC, arrays are accessed using the parenthesis operator (''('' and '')'') next to the name of the variable that contains the array. The indices must be inserted inside the brackets to access the individual elements of the array. There is no limit to the number of dimensions: however, the cardinality of indices must be the same as the one used when defining the array itself. There is, also, a limit related to memory availability. Furthermore, access to locations is not controlled and therefore particular care must be taken not to exceed the boundaries of the area intended to hold the information on the array. When an array is accessed, it can be done in two ways: to retrieve a value (read access) or to set a value (write access). Read access occurs any time the array is used in an expression. Conversely, for write access, the indexed array must be used as the target 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 ==== readElement = a(42,3) b(1,1) = 42 word = words$(42) words$(1) = "ok!" ==== AVAILABLE ON ==== * Atari (400/800) * Atari XL/XE * Commodore 128 (MOS 8502) * Commodore 128 (Zilog Z80) * Commodore 64 * Commodore 64+REU * 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 [[https://github.com/spotlessmind1975/ugbasic/issues/new?title=ISSUE ON array operator|open an issue]] for this keyword on GitHub. Thank you!===== POWERED BY ===== [[:ugbasic:user:index|{{ :ugbasic:user:logo-ugbasic.png?nolink&600 |}}]]