With : EndWith
DescriptionWith <expression> ... EndWith
With : EndWith block allows to reduce the amount of code to type and ease its readibility when using a lot of structure fields. It contains regular PureBasic code, and automatically inserts the specified expression before any anti-slash '\' character which does have a space or an operator before it. This is a compiler directive, and works like a macro: the line is expanded at compile time. With : EndWith blocks can not be nested, as it could introduce hard to track bugs, when having several implicitely replaced statement with different values.Example:
Structure Person Name$ Age.l Size.l EndStructure Friend.Person With Friend \Name$ = "Yann" \Age = 30 \Size = 196 Debug \Size+\Size EndWithExample: 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