@Option Directive

Makes sure that your code agrees with a given style or syntax. And also lets you change how some functions operate.

Syntax

@Option options…

Parts

options
Mandatory one or more identifiers

Instructions

Args

@Option Args ByName { Boolean | Literal }

Procedure calls that have one or more Booleans or literals for arguments can show a warning if not passed by name. The warning is applicable only if you supply two or more such arguments to the procedure. The warning has a level of Warning4.

See Passing Arguments by Position and by Name for more information.

@Option Args Enclosed

You must write parentheses (( )) around (1) arguments for procedure calls and (2) parameters for procedure declarations. Procedure declarations start with one of these keywords: Function, Method, or Sub. You must supply empty parentheses if a procedure has no parameters. And if a procedure call does not have arguments, you must write empty parentheses or a question mark (?).

Charset

@Option charset Latin

All names must use the Latin character set. That is letters (‘A’ thru ‘Z’), digits (‘0’ thru ‘9’), and underscores (‘_’).

Dim

@Option Dim

You must start a variable declaration with Dim, and not Var. For example:

Dim x As Int32

@Option Var

You must start a variable declaration with Var, and not Dim. For example:

Var x As Int32

End

@Option End Block

You must write End plus the block type. For example:

While condition
  ' ...
End While

@Option End [ No Block ]

You must write End without the block type. For example:

While condition
  ' ...
End

@Option End For ID

You can use this only with “@Option End Block”. You must complete all statements of the type Forwith End For, plus the loop counter. For example:

For index = 1 To 10
  ' ...
End For index

@Option End For [ No ID ]

You can use this only with “@Option End 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

Enum

@Option Enum ID

You must give a name to all statements of the type Enum. For example:

Enum DogBreed
  ' ...
End

@Option Enum Is

You must give statements of the type Enum a data type, with the clause Is. For example:

Enum Is UInt16
  ' ...
End

@Option Enum Equals

You must give members of the statement Enum values, assigned with the operator “=”. For example:

Enum
  first  = 1
  second = 2
End

If

@Option If Then

You must write Then with all statements of the type If…Else. For example:

If condition1 Then
  ' ...
Else If condition2 Then
  ' ...
End

@Option If [ No Then ]

You must not write Then with the block construct of the statement If…Else. For example:

If condition1
  ' ...
Else If condition2
  ' ...
End

@Option If End

You must complete statements of the type If…Else with End or End If. If you use “@Option End Block”, you must write End If. Thus, use of the one-line construct becomes an error.

Last

@Option Last

No more directives of the type @Option are permitted after this one.

Mod

@Option Mod Floored

Changes how the operators Mod and Mod= operate. Usually the two operators Mod and Rem operate the same. They return the remainder after division.

Usually the sign of the remainder comes from the left side, or dividend. This type of operation is known as truncated modulo. But this directive causes the sign of the remainder to come from the right side, or divisor. This alternative operation is known as floored modulo.

Mod results
ExampleTruncatedFloored
+9 Mod +4  1  1
-9 Mod +4 -1  1
+9 Mod -4  1 -1
-9 Mod -4 -1 -1

New

@Option New

You must start New Statements with New. If you use “@Option End Block”, you must complete the block construct with End New. For example:

New Files #logs, "*.log"

New Menu #file, "File"
Begin
  ' ...
End New

Optional

@Option Optional Equals

You must give a value to an optional parameter with the operator “=”. For example:

Method ReadData(Optional path As String = ".")
  ' ...
End

Select

@Option Select Case

You must write Select Case in all statements of the type Select…Case. For example:

Select Case test
  ' ...
End

@Option Select [ No Case ]

You must not write the keyword Case after Select in all statements of the type Select…Case.

@Option Select Strict

You must do something for all possible values of the test expressions of statements of the type select…Case. You can try to supply a sufficient number of values with the clause Case. But if that is not possible, you must supply the clause Case Else. This is the same as if you used the modifier @Strict with all such statements. For example:

Select minutes
Case 0 To 29
  ' ...
Case 30 To 59
  ' ...
Case Else
  Raise RangeError(minutes)
End

@Option Select Strict String

You must write the clause “Case Else” for all statements of the type Select…Case that compare strings. But Case Else will not be mandatory for other data types.

String

@Option String Backslash

You must write a path string with backslashes, not slashes. For example:

Const BITMAP_DIR = "media"\"bmp"

@Option String Slash

You must write a path string with slashes, not backslashes. For example:

Const BITMAP_DIR = "media"/"bmp"

Test

@Option Test

The module contains only unit tests. A unit test is a procedure with the modifier @Test. See @Test for more information.

@Option Test Compiler

Causes ViviFire to parse inline comments to find commands used in tests of the compiler. You must not use this directive unless you do work on the compiler. Block comments are ignored as usual.

These commands (expect-error and expect-warning) cause the compiler to ignore errors and warnings before the applicable command. The comment must be on the same line as the statement, or the line immediately after the statement.

Then you must write the error or warning message between a pair of two braces ({{ }}). The compiler ignores the remaining comment until the end of the line.

An example follows.

@Option Test Compiler

x = 1 // expect-error {{Variable was not declared}} TBD

Const _BAD_NAME = "The user name is not valid."
    ' expect-error {{Invalid Name}}

Type

@Option Type { Each | Param | Var }

You must supply a data type for each name in the given location.

You can supply the data type as follows:

Without this directive, you can write code as follows:

Sub Add(a, b As Int32) As Int32
    Return a + b
End Sub

Var x, y, sum As Int32
PromptInput "Enter first number: ", x
PromptInput "Enter second number: ", y
sum = Add(x, y)
PrintLine "The sum of {x} and {y} is {sum}."

With Type Param (or Type Each), The line that follows becomes an error.

Sub Add(a, b As Int32) As Int32

You must change it to the code that follows:

Sub Add(a As Int32, b As Int32) As Int32

With Type Var (or Type Each), the line that follows is a also an error.

Var x, y, sum As Int32

You must change it to the code that follows:

Var x As Int32, y As Int32, sum As Int32

Unit

@Option Unit Full

You must write the full names of units of measure. Thus “kilometer” is correct syntax, but “km” is incorrect.

Warning

@Option Warning[1-5]

Warning levels
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.

@Option Warning[1-5] Error

When you add 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 Error
@Option Warning5

When

@Option When Each

You must write When Each, and not When Else, for statements in the block Exit When. For example:

While condition
Exit When
    ' ...
When Each
    ' ...
End

@Option When Else

You must write When Else, and not When Each, for statements in the block Exit When. For example:

While condition
Exit When
    ' ...
When Else
    ' ...
End

@Option When ID

You must write all the labels that are after each When (in a loop) also after Exit When. Thus it becomes an error not to supply this list. For example:

While NextResult?
Exit When found ' mandatory
When Each
    ' ...
When found
    ' ...
End

See also