With
 
Statement block to allow implicit access to fields in a user defined type variable

Syntax

With user_defined_var
statements
End With

Description

The With...End With block allows the omission of the name of a user defined variable when referring to its fields. It's a shorthand to save typing and avoid cluttering the source. With can also be used with dereferenced pointers, as the second example shows.

Example

Type rect_type
    x As Single
    y As Single
End Type

Dim the_rectangle As rect_type
Dim As Integer temp, t

With the_rectangle
    temp = .x
    .x = 234 * t + 48 + .y
    .y = 321 * t + 2
End With


Type rect_type
    x As Single
    y As Single
End Type

Dim the_rectangle As rect_type Ptr

the_rectangle = CAllocate( 5 * Len( rect_type ) )

Dim As Integer loopvar, temp, t

For loopvar = 0 To 4

  With the_rectangle[loopvar]

    temp = .x
    .x = 234 * t + 48 + .y
    .y = 321 * t + 2

  End With

Next



Dialect Differences

  • Not available in the -lang qb dialect unless referenced with the alias __With.

Differences from QB

  • New to FreeBASIC

See also