@Option Directive
Makes sure that your code agrees with a given style.
Syntax
@Option options
Parts
options
- Mandatory one or more identifiers
Instructions
Charset Latin
All names must use the Latin character set. That is letters (‘A’ thru ‘Z’), digits (‘0’ thru ‘9’), and underscores (‘_’).
Dim
Dim With Dim
You must start a variable declaration with Dim
, and not Var
.
For example:
Dim x As Int
Dim With Var
You must start a variable declaration with Var
, and not Dim
.
For example:
Var x As Int
End
End For With Name
You can use this only with “@Option End With Block
”.
You must complete all statements of the type For
with End For
, plus the loop counter.
For example:
For index = 1 To 10
' ...
End For index
End For Without Name
You can use this only with “@Option End With Block
”.
You must complete all statements of the type For
with End For
, without the loop counter.
For example:
For index = 1 To 10
' ...
End For
End With Block
You must write End
plus the block type.
For example:
While condition
' ...
End While
End Without Block
You must write End
without the block type.
For example:
While condition
' ...
End
Enum
Enum With Name
You must give a name to all statements of the type Enum
.
For example:
Enum DogBreed
' ...
End
Enum With Type
You must give statements of the type Enum
a data type, with the clause Is
.
For example:
Enum Is UInt16
' ...
End
Enum With Equals
You must give members of the statement Enum
values, assigned with the operator “=
”.
For example:
Enum
first = 1
second = 2
End
If
If With End
You must complete statements of the type If…Else
with End
or End If
.
If you use “@Option End With Block
”, then you must write End If
.
Thus, use of the one-line construct becomes an error.
If With Then
You must write Then
with all statements of the type If…Else
.
For example:
If condition1 Then
' ...
Else If condition2 Then
' ...
End
If Without Then
You must not write Then
with the block construct of the statement If…Else
.
For example:
If condition1
' ...
Else If condition2
' ...
End
Last
No more directives of the type @Option
are permitted after this one.
New
New With New
You must start New
Statements with New
.
If you use “@Option End With Block
”, then you must complete the block construct with End New
.
For example:
New Files #logs, "*.log"
New Menu #file, "File"
Begin
' ...
End New
New Without New
You must start New
Statements with the data type, not New
.
If you use “@Option End With Block
”, then you must complete the block construct with End
plus the data type.
For example:
Files #logs, "*.log"
Menu #file, "File"
Begin
' ...
End Menu
Optional With Equals
You must give a value to an optional parameter with the “=
” operator.
For example:
Method ReadData(Optional path As String = ".")
' ...
End
Select
Select With Case
You must write Select Case
in all statements of the type Select…Case
.
For example:
Select Case test
' ...
End
Select With Else
You must write the clause Case Else
for all statements of the type Select…Case
.
This is to make sure that you do something for all possible values.
For example:
Select minutes
Case 0 To 29
' ...
Case 30 To 59
' ...
Case Else
Raise RangeError(minutes)
End
Select Without Case
You must not write the keyword Case
after Select
in all statements of the type Select…Case
.
Unit With Name
You must write the full names of units of measure. Thus “kilometer” is correct syntax, but “km” is incorrect.
Warning
Option | ViviFire shows |
---|---|
Warning1 |
Only warnings with a risk more than 75% to cause problems |
Warning2 |
Only warnings with a risk more than 50% to cause problems |
Warning3 |
Only warnings with a risk more than 25% to cause problems |
Warning4 or Warning |
Only warnings with a risk more than 0% to cause problems (Default) |
Warning5 |
All warnings, if they cause problems or not. |
Warning[1-5] As Error
When you add As Error
, all warnings at that level and below become errors.
You can use the two syntaxes together if the level for errors is less than the level for warnings.
An example follows.
@Option Warning1 As Error
@Option Warning5