With : EndWith


Syntax
With <expression>
  ...
EndWith
Description
With : EndWith blocks may be used with structure fields in order to reduce the quantity of code and to improve its' readability. This is a compiler directive, and works similarly to a macro, i.e., the specified expression is automatically inserted before any anti-slash '\' character which does not have a space or an operator preceding it. The code behaves identically to its' expanded version. With : EndWith blocks may not be nested, as this could introduce bugs which are difficult to track under conditions where several statements have been replaced implicitly.

Example

  Structure Person
    Name$
    Age.l
    Size.l
  EndStructure

  Friend.Person
  
  With Friend
    \Name$ = "Yann"
    \Age   = 30
    \Size  = 196
    
    Debug \Size+\Size
  EndWith
    

Example: Complex example

  Structure Body
    Weight.l
    Color.l
    Texture.l
  EndStructure

  Structure Person
    Name$
    Age.l
    Body.Body[10]
  EndStructure

  Friend.Person
  
  For k = 0 To 9
    With Friend\Body[k]
      \Weight = 50
      \Color  = 30
      \Texture = \Color*k
      
      Debug \Texture
    EndWith
  Next