| Home | | | Quick start | | | Cookbook | | | All symbols | | | Analytical index | | | Namespaces | | | Syntax | | | Statements | | | CX | | | Frequency | | | Functions | | | Examples | | | Examples by command |
Language keywords, runtime helpers and non-namespaced symbols.
Symbols in this namespace: 43
| Symbol | Kind | Category | Description |
|---|---|---|---|
AND | Keyword | Language keywords | Logical AND operator. |
ARRAY | Keyword | Language keywords | Logical type returned by TYPE(x) for arrays. |
AS | Keyword | Language keywords | Assigns the result of a command to a variable, or names the local return variable in FUNCTION ... AS result. |
ASSERT | Command | Diagnostics statements | Stops the script with a clear error if condition is false. Useful for diagnostic and regression scripts. |
CALL | Keyword | Language keywords | Executes a SUB block. Simple variable arguments are copied back after the call. |
CASE | Keyword | Language keywords | Introduces one SWITCH branch. Multiple comma-separated values are allowed. Numeric ranges and comparisons are supported. Only the first matching branch is executed. |
CATCH | Keyword | Language keywords | Handles a runtime error from the preceding TRY block. Optional variables receive the message and source line. |
COUNT_NONZERO | Function | OpenCV / media functions | Compatibility alias for COUNT_NONZERO / MASK.COUNT. |
DEFAULT | Keyword | Language keywords | Optional fallback branch of a SWITCH block. It must appear after all CASE branches. |
DIM | Command | Core statements | Declares a zero-based one or multi-dimensional array. Variable names are case-insensitive, so DIM v(10) and later V refer to the same variable. Compact literals are also supported: v = [1,2,3] and A = [[1,2],[3,4]]. |
DIM | Command | Language keywords | Declares a zero-based one or multi-dimensional array. Variable names are case-insensitive, so DIM v(10) and later V refer to the same variable. Compact literals are also supported: v = [1,2,3] and A = [[1,2],[3,4]]. |
ELSE | Keyword | Language keywords | Alternative branch of an IF block. |
ENDFUNCTION | Keyword | Language keywords | Closes a FUNCTION block. |
ENDIF | Keyword | Language keywords | Closes the IF block. |
ENDSUB | Keyword | Language keywords | Closes a SUB block. |
ENDSWITCH | Keyword | Language keywords | Closes a SWITCH block. |
ENDTRY | Keyword | Language keywords | Closes a TRY/CATCH block. |
EXIT | Keyword | Language keywords | Terminates the current script cleanly. Useful in interactive scripts after a cancelled dialog or an explicit user choice. |
FALSE | Keyword | Language keywords | Boolean false constant. |
FOR | Keyword | Language keywords | Starts either a numeric loop or a FOR IN iteration over all elements of an array/string. |
FUNCTION | Keyword | Language keywords | Starts a user-defined function block. The function can be used inside expressions and returns either RETURN expr or the AS return variable. |
IF | Keyword | Language keywords | Starts a conditional block. If a statement follows THEN on the same line, it is executed as a one-line IF without requiring ENDIF. |
IMAGE | Keyword | Language keywords | Logical type returned by TYPE(x) for single images. |
IN | Keyword | Language keywords | Introduces the collection expression in a FOR IN loop. Arrays are iterated in row-major linear order; strings are iterated character by character. |
INCLUDE | Keyword | Language keywords | Alias of USING. Includes another cvBasic source file before execution, with the same path resolution, nested include support and recursive cycle protection. |
LET | Keyword | Language keywords | Explicit assignment; equivalent to using =. Variables are case-insensitive: k and K are the same variable, so scientific scripts should prefer descriptive names such as springK and kinEnergy. Array elements may be assigned with A[i,j] = value or legacy A(i,j) = value. |
NEXT | Keyword | Language keywords | Closes the FOR loop. |
NOT | Keyword | Language keywords | Logical negation. |
OR | Keyword | Language keywords | Logical OR operator. |
PRINT | Command | Core statements | Writes the provided values to the log output. |
REM | Keyword | Language keywords | Starts a BASIC-style comment. Text after REM is ignored when REM is used as a standalone token. |
RETURN | Keyword | Language keywords | Exits the current SUB or returns expr from the current FUNCTION. |
STACK | Keyword | Language keywords | Logical type returned by TYPE(x) for frame stacks. |
STEP | Keyword | Language keywords | Increment of the numeric FOR loop. |
SUB | Keyword | Language keywords | Starts a named subroutine block. The block is skipped during normal flow and executed only by CALL. |
SWITCH | Keyword | Language keywords | Starts a multi-branch selection block. The expression is evaluated once and compared with each CASE value, range or numeric comparison. |
THEN | Keyword | Language keywords | Separates the condition from the true branch. A statement after THEN creates a one-line IF. |
TO | Keyword | Language keywords | Specifies the final value of the FOR loop. |
TRUE | Keyword | Language keywords | Boolean true constant. |
TRY | Keyword | Language keywords | Starts a protected block. Runtime errors raised before CATCH are intercepted instead of stopping the script. |
USING | Keyword | Language keywords | Includes another cvBasic source file before execution. Relative paths are resolved from the current script or included file directory; recursive include cycles are rejected. INCLUDE is an exact alias of USING. Rev 10.0 also supports ':' between simple statements and '_' as a line-continuation marker. |
WEND | Keyword | Language keywords | Closes the WHILE loop. |
WHILE | Keyword | Language keywords | Starts a conditional loop. |
expr AND expr
Logical AND operator.
IF NOT CV.IS_STACK(img) AND CV.WIDTH(img) > 0 THEN
PRINT "single image"
ENDIFARRAY
Logical type returned by TYPE(x) for arrays.
ARRAY... AS name
Assigns the result of a command to a variable, or names the local return variable in FUNCTION ... AS result.
CV.GRAY img AS grayASSERT condition [, message]
Stops the script with a clear error if condition is false. Useful for diagnostic and regression scripts.
Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.
| Parameter | Meaning |
|---|---|
message | Optional parameter. If omitted, the command uses its internal default. |
ASSERT CV.WIDTH(img) = 64, "Unexpected image width"CALL name([arg1 [, arg2 ...]])
Executes a SUB block. Simple variable arguments are copied back after the call.
Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.
| Parameter | Meaning |
|---|---|
arg1 | Optional parameter. If omitted, the command uses its internal default. |
arg2 | Optional parameter. If omitted, the command uses its internal default. |
SUB PROCESS_IMAGE(src, dst)
CV.GRAY src AS g
CV.CLAHE g, 2.0, 8 AS dst
ENDSUB
CALL PROCESS_IMAGE(img, enhanced)
FUNCTION DOUBLE_VALUE(x)
RETURN x * 2
ENDFUNCTIONCASE expression [, expression ...] | CASE low TO high | CASE > expr
Introduces one SWITCH branch. Multiple comma-separated values are allowed. Numeric ranges and comparisons are supported. Only the first matching branch is executed.
Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.
| Parameter | Meaning |
|---|---|
expression | Optional parameter. If omitted, the command uses its internal default. |
SWITCH score
CASE 0 TO 30
PRINT "low"
CASE 31 TO 70
PRINT "medium"
CASE > 70
PRINT "high"
DEFAULT
PRINT "invalid"
ENDSWITCHCATCH [errVar [, lineVar]]
Handles a runtime error from the preceding TRY block. Optional variables receive the message and source line.
Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.
| Parameter | Meaning |
|---|---|
errVar | Optional parameter. If omitted, the command uses its internal default. |
lineVar | Optional parameter. If omitted, the command uses its internal default. |
TRY
IO.LOAD "missing.png" AS img
CATCH err, line
PRINT "Error at line "; line; ": "; err
ENDTRYMASK.COUNT_NONZERO(mask)
Compatibility alias for COUNT_NONZERO / MASK.COUNT.
n = MASK.COUNT_NONZERO(mask)DEFAULT
Optional fallback branch of a SWITCH block. It must appear after all CASE branches.
SWITCH score
CASE 0 TO 30
PRINT "low"
CASE 31 TO 70
PRINT "medium"
CASE > 70
PRINT "high"
DEFAULT
PRINT "invalid"
ENDSWITCHDIM name(size1 [, size2 ...])
Declares a zero-based one or multi-dimensional array. Variable names are case-insensitive, so DIM v(10) and later V refer to the same variable. Compact literals are also supported: v = [1,2,3] and A = [[1,2],[3,4]].
Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.
| Parameter | Meaning |
|---|---|
size2 | Optional parameter. If omitted, the command uses its internal default. |
v = [10, 20, 30]
A = [[1, 2], [3, 4]]
PRINT v[1], A[1,0]DIM name(size1 [, size2 ...])
Declares a zero-based one or multi-dimensional array. Variable names are case-insensitive, so DIM v(10) and later V refer to the same variable. Compact literals are also supported: v = [1,2,3] and A = [[1,2],[3,4]].
Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.
| Parameter | Meaning |
|---|---|
size2 | Optional parameter. If omitted, the command uses its internal default. |
v = [10, 20, 30]
A = [[1, 2], [3, 4]]
PRINT v[1], A[1,0]ELSE
Alternative branch of an IF block.
IF CV.WIDTH(img) > 512 THEN
PRINT "large image"
ELSE
PRINT "small image"
ENDIFENDFUNCTION
Closes a FUNCTION block.
FUNCTION CONTRAST_SCORE(img)
RETURN CV.STDDEV(img)
ENDFUNCTION
score = CONTRAST_SCORE(gray)ENDIF
Closes the IF block.
IF CV.WIDTH(img) > 512 THEN
PRINT "large image"
ELSE
PRINT "small image"
ENDIFENDSUB
Closes a SUB block.
SUB PROCESS_IMAGE(src, dst)
CV.GRAY src AS g
CV.CLAHE g, 2.0, 8 AS dst
ENDSUB
CALL PROCESS_IMAGE(img, enhanced)
FUNCTION DOUBLE_VALUE(x)
RETURN x * 2
ENDFUNCTIONENDSWITCH
Closes a SWITCH block.
SWITCH score
CASE 0 TO 30
PRINT "low"
CASE 31 TO 70
PRINT "medium"
CASE > 70
PRINT "high"
DEFAULT
PRINT "invalid"
ENDSWITCHENDTRY
Closes a TRY/CATCH block.
TRY
IO.LOAD "missing.png" AS img
CATCH err, line
PRINT "Error at line "; line; ": "; err
ENDTRYEXIT
Terminates the current script cleanly. Useful in interactive scripts after a cancelled dialog or an explicit user choice.
path = GUI.GET_OPEN_FILE_NAME("Open image")
IF path = "" THEN
EXIT
ENDIFFALSE
Boolean false constant.
FALSEFOR var = start TO end [STEP step] | FOR elem IN arrayExpr
Starts either a numeric loop or a FOR IN iteration over all elements of an array/string.
Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.
| Parameter | Meaning |
|---|---|
STEP | Optional parameter. If omitted, the command uses its internal default. |
FOR i = 0 TO 9 STEP 1
PRINT i
NEXT
FOR value IN samples
PRINT value
NEXTFUNCTION name([param1 [, param2 ...]]) [AS returnVar]
Starts a user-defined function block. The function can be used inside expressions and returns either RETURN expr or the AS return variable.
Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.
| Parameter | Meaning |
|---|---|
param1 | First algorithm-specific tuning parameter. |
param2 | Second algorithm-specific tuning parameter. |
returnVar | Optional parameter. If omitted, the command uses its internal default. |
FUNCTION CONTRAST_SCORE(img)
RETURN CV.STDDEV(img)
ENDFUNCTION
score = CONTRAST_SCORE(gray)IF condition THEN [statement]
Starts a conditional block. If a statement follows THEN on the same line, it is executed as a one-line IF without requiring ENDIF.
Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.
| Parameter | Meaning |
|---|---|
statement | Optional parameter. If omitted, the command uses its internal default. |
IF CV.WIDTH(img) > 512 THEN
PRINT "large image"
ELSE
PRINT "small image"
ENDIF
IF v < 0 THEN v = 0IMAGE
Logical type returned by TYPE(x) for single images.
IMAGEFOR elem IN arrayExpr
Introduces the collection expression in a FOR IN loop. Arrays are iterated in row-major linear order; strings are iterated character by character.
FOR i = 0 TO 9 STEP 1
PRINT i
NEXT
DIM values(3)
values(0) = 10
values(1) = 20
values(2) = 30
FOR v IN values
PRINT v
NEXTINCLUDE "library.cvb"
Alias of USING. Includes another cvBasic source file before execution, with the same path resolution, nested include support and recursive cycle protection.
INCLUDE "lib/algebra_utils.cvb"
PRINT VEC2_NORM([3, 4])LET var = expr
Explicit assignment; equivalent to using =. Variables are case-insensitive: k and K are the same variable, so scientific scripts should prefer descriptive names such as springK and kinEnergy. Array elements may be assigned with A[i,j] = value or legacy A(i,j) = value.
A = [[1, 2], [3, 4]]
A[0,1] = 9
PRINT A[0,1]NEXT
Closes the FOR loop.
FOR i = 0 TO 9 STEP 1
PRINT i
NEXT
DIM values(3)
values(0) = 10
values(1) = 20
values(2) = 30
FOR v IN values
PRINT v
NEXTNOT expr
Logical negation.
IF NOT CV.IS_STACK(img) AND CV.WIDTH(img) > 0 THEN
PRINT "single image"
ENDIFexpr OR expr
Logical OR operator.
IF NOT CV.IS_STACK(img) AND CV.WIDTH(img) > 0 THEN
PRINT "single image"
ENDIFPRINT expr1 [; expr2 ...] [, exprN ...]
Writes the provided values to the log output.
Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.
| Parameter | Meaning |
|---|---|
expr2 | Optional parameter. If omitted, the command uses its internal default. |
exprN | Optional parameter. If omitted, the command uses its internal default. |
PRINT "Width="; CV.WIDTH(img); " Height="; CV.HEIGHT(img)REM text
Starts a BASIC-style comment. Text after REM is ignored when REM is used as a standalone token.
REMRETURN [expr]
Exits the current SUB or returns expr from the current FUNCTION.
Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.
| Parameter | Meaning |
|---|---|
expr | Optional parameter. If omitted, the command uses its internal default. |
SUB PROCESS_IMAGE(src, dst)
CV.GRAY src AS g
CV.CLAHE g, 2.0, 8 AS dst
ENDSUB
CALL PROCESS_IMAGE(img, enhanced)
FUNCTION DOUBLE_VALUE(x)
RETURN x * 2
ENDFUNCTIONSTACK
Logical type returned by TYPE(x) for frame stacks.
STACKFOR var = start TO end [STEP step]
Increment of the numeric FOR loop.
Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.
| Parameter | Meaning |
|---|---|
STEP | Optional parameter. If omitted, the command uses its internal default. |
FOR i = 0 TO 9 STEP 1
PRINT i
NEXT
DIM values(3)
values(0) = 10
values(1) = 20
values(2) = 30
FOR v IN values
PRINT v
NEXTSUB name([param1 [, param2 ...]])
Starts a named subroutine block. The block is skipped during normal flow and executed only by CALL.
Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.
| Parameter | Meaning |
|---|---|
param1 | First algorithm-specific tuning parameter. |
param2 | Second algorithm-specific tuning parameter. |
SUB PROCESS_IMAGE(src, dst)
CV.GRAY src AS g
CV.CLAHE g, 2.0, 8 AS dst
ENDSUB
CALL PROCESS_IMAGE(img, enhanced)SWITCH expression
Starts a multi-branch selection block. The expression is evaluated once and compared with each CASE value, range or numeric comparison.
SWITCH score
CASE 0 TO 30
PRINT "low"
CASE 31 TO 70
PRINT "medium"
CASE > 70
PRINT "high"
DEFAULT
PRINT "invalid"
ENDSWITCHIF condition THEN [statement]
Separates the condition from the true branch. A statement after THEN creates a one-line IF.
Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.
| Parameter | Meaning |
|---|---|
statement | Optional parameter. If omitted, the command uses its internal default. |
IF CV.WIDTH(img) > 512 THEN
PRINT "large image"
ELSE
PRINT "small image"
ENDIFFOR var = start TO end [STEP step]
Specifies the final value of the FOR loop.
Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.
| Parameter | Meaning |
|---|---|
STEP | Optional parameter. If omitted, the command uses its internal default. |
FOR i = 0 TO 9 STEP 1
PRINT i
NEXT
DIM values(3)
values(0) = 10
values(1) = 20
values(2) = 30
FOR v IN values
PRINT v
NEXTTRUE
Boolean true constant.
TRUETRY
Starts a protected block. Runtime errors raised before CATCH are intercepted instead of stopping the script.
TRY
IO.LOAD "missing.png" AS img
CATCH err, line
PRINT "Error at line "; line; ": "; err
ENDTRYUSING "library.cvb"
Includes another cvBasic source file before execution. Relative paths are resolved from the current script or included file directory; recursive include cycles are rejected. INCLUDE is an exact alias of USING. Rev 10.0 also supports ':' between simple statements and '_' as a line-continuation marker.
USING "lib/image_quality.cvb"
score = CONTRAST_SCORE(img)WEND
Closes the WHILE loop.
i = 0
WHILE i < 3
PRINT i
i = i + 1
WENDWHILE condition
Starts a conditional loop.
i = 0
WHILE i < 3
PRINT i
i = i + 1
WEND