Syntax

Opens a block where \field stands for <record>.field, anywhere on the line, to write less when many lines touch one record.

WITH <record>
  \<field> …
  \<field>\<subfield> …
  \<field>.<subfield> …
ENDWITH
END WITH

Also written : ENDWITH

Parts

<record>Any record expression: a variable, fleet(i), the current list element foes().
<field>A field of the record.
<subfield>A field of a record field. Write the chain with \ or with ..

Good to know

  • The block closes with ENDWITH or END WITH.
  • The record expression is re-read at every \. With WITH fleet(i), changing i inside the block moves the following lines to another cell.
  • WITH blocks do not nest. A WITH inside a WITH is a compile error: "Nested WITH blocks are not supported".
  • Text in strings and comments is left alone: "C:\games" stays a path.
  • Outside a WITH, hero\fuel is refused with "Not a BASIC statement". Write hero.fuel.
  • One word after WITH makes a record block. Two words, the first a command family (WITH SPRITE s), make the command shorthand instead.

Example

TYPE Vec  x AS float  y AS floatENDTYPETYPE Ship  name AS string  fuel AS integer  pos AS VecENDTYPEs AS ShipWITH s  \name = "Comet"  \fuel = 80  \pos\x = 1.5  \pos.y = 2.5  Console(\name + " " + Str(\fuel) + " " + Str(\pos\x + \pos\y))   ' Comet 80 4ENDWITH
In the manual : Records and methods