CORE namespace

Language keywords, runtime helpers and non-namespaced symbols.

Symbols in this namespace: 43

SymbolKindCategoryDescription
ANDKeywordLanguage keywordsLogical AND operator.
ARRAYKeywordLanguage keywordsLogical type returned by TYPE(x) for arrays.
ASKeywordLanguage keywordsAssigns the result of a command to a variable, or names the local return variable in FUNCTION ... AS result.
ASSERTCommandDiagnostics statementsStops the script with a clear error if condition is false. Useful for diagnostic and regression scripts.
CALLKeywordLanguage keywordsExecutes a SUB block. Simple variable arguments are copied back after the call.
CASEKeywordLanguage keywordsIntroduces one SWITCH branch. Multiple comma-separated values are allowed. Numeric ranges and comparisons are supported. Only the first matching branch is executed.
CATCHKeywordLanguage keywordsHandles a runtime error from the preceding TRY block. Optional variables receive the message and source line.
COUNT_NONZEROFunctionOpenCV / media functionsCompatibility alias for COUNT_NONZERO / MASK.COUNT.
DEFAULTKeywordLanguage keywordsOptional fallback branch of a SWITCH block. It must appear after all CASE branches.
DIMCommandCore statementsDeclares 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]].
DIMCommandLanguage keywordsDeclares 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]].
ELSEKeywordLanguage keywordsAlternative branch of an IF block.
ENDFUNCTIONKeywordLanguage keywordsCloses a FUNCTION block.
ENDIFKeywordLanguage keywordsCloses the IF block.
ENDSUBKeywordLanguage keywordsCloses a SUB block.
ENDSWITCHKeywordLanguage keywordsCloses a SWITCH block.
ENDTRYKeywordLanguage keywordsCloses a TRY/CATCH block.
EXITKeywordLanguage keywordsTerminates the current script cleanly. Useful in interactive scripts after a cancelled dialog or an explicit user choice.
FALSEKeywordLanguage keywordsBoolean false constant.
FORKeywordLanguage keywordsStarts either a numeric loop or a FOR IN iteration over all elements of an array/string.
FUNCTIONKeywordLanguage keywordsStarts a user-defined function block. The function can be used inside expressions and returns either RETURN expr or the AS return variable.
IFKeywordLanguage keywordsStarts a conditional block. If a statement follows THEN on the same line, it is executed as a one-line IF without requiring ENDIF.
IMAGEKeywordLanguage keywordsLogical type returned by TYPE(x) for single images.
INKeywordLanguage keywordsIntroduces the collection expression in a FOR IN loop. Arrays are iterated in row-major linear order; strings are iterated character by character.
INCLUDEKeywordLanguage keywordsAlias of USING. Includes another cvBasic source file before execution, with the same path resolution, nested include support and recursive cycle protection.
LETKeywordLanguage keywordsExplicit 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.
NEXTKeywordLanguage keywordsCloses the FOR loop.
NOTKeywordLanguage keywordsLogical negation.
ORKeywordLanguage keywordsLogical OR operator.
PRINTCommandCore statementsWrites the provided values to the log output.
REMKeywordLanguage keywordsStarts a BASIC-style comment. Text after REM is ignored when REM is used as a standalone token.
RETURNKeywordLanguage keywordsExits the current SUB or returns expr from the current FUNCTION.
STACKKeywordLanguage keywordsLogical type returned by TYPE(x) for frame stacks.
STEPKeywordLanguage keywordsIncrement of the numeric FOR loop.
SUBKeywordLanguage keywordsStarts a named subroutine block. The block is skipped during normal flow and executed only by CALL.
SWITCHKeywordLanguage keywordsStarts a multi-branch selection block. The expression is evaluated once and compared with each CASE value, range or numeric comparison.
THENKeywordLanguage keywordsSeparates the condition from the true branch. A statement after THEN creates a one-line IF.
TOKeywordLanguage keywordsSpecifies the final value of the FOR loop.
TRUEKeywordLanguage keywordsBoolean true constant.
TRYKeywordLanguage keywordsStarts a protected block. Runtime errors raised before CATCH are intercepted instead of stopping the script.
USINGKeywordLanguage keywordsIncludes 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.
WENDKeywordLanguage keywordsCloses the WHILE loop.
WHILEKeywordLanguage keywordsStarts a conditional loop.

AND

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

expr AND expr

Logical AND operator.

Minimal example

IF NOT CV.IS_STACK(img) AND CV.WIDTH(img) > 0 THEN
    PRINT "single image"
ENDIF

ARRAY

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

ARRAY

Logical type returned by TYPE(x) for arrays.

Minimal example

ARRAY

AS

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

... AS name

Assigns the result of a command to a variable, or names the local return variable in FUNCTION ... AS result.

Minimal example

CV.GRAY img AS gray

ASSERT

STATEMENTBATCH-FRIENDLY
Kind: Command   Category: Diagnostics statements   Namespace: CORE

ASSERT condition [, message]

Stops the script with a clear error if condition is false. Useful for diagnostic and regression scripts.

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
messageOptional parameter. If omitted, the command uses its internal default.

Minimal example

ASSERT CV.WIDTH(img) = 64, "Unexpected image width"

CALL

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

CALL name([arg1 [, arg2 ...]])

Executes a SUB block. Simple variable arguments are copied back after the call.

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
arg1Optional parameter. If omitted, the command uses its internal default.
arg2Optional parameter. If omitted, the command uses its internal default.

Minimal example

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
ENDFUNCTION

CASE

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

CASE 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.

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
expressionOptional parameter. If omitted, the command uses its internal default.

Minimal example

SWITCH score
CASE 0 TO 30
    PRINT "low"
CASE 31 TO 70
    PRINT "medium"
CASE > 70
    PRINT "high"
DEFAULT
    PRINT "invalid"
ENDSWITCH

CATCH

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

CATCH [errVar [, lineVar]]

Handles a runtime error from the preceding TRY block. Optional variables receive the message and source line.

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
errVarOptional parameter. If omitted, the command uses its internal default.
lineVarOptional parameter. If omitted, the command uses its internal default.

Minimal example

TRY
    IO.LOAD "missing.png" AS img
CATCH err, line
    PRINT "Error at line "; line; ": "; err
ENDTRY

COUNT_NONZERO

FUNCTIONBATCH-FRIENDLYIMAGE
Kind: Function   Category: OpenCV / media functions   Namespace: CORE

MASK.COUNT_NONZERO(mask)

Compatibility alias for COUNT_NONZERO / MASK.COUNT.

Minimal example

n = MASK.COUNT_NONZERO(mask)

DEFAULT

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

DEFAULT

Optional fallback branch of a SWITCH block. It must appear after all CASE branches.

Minimal example

SWITCH score
CASE 0 TO 30
    PRINT "low"
CASE 31 TO 70
    PRINT "medium"
CASE > 70
    PRINT "high"
DEFAULT
    PRINT "invalid"
ENDSWITCH

DIM

STATEMENTBATCH-FRIENDLY
Kind: Command   Category: Core statements   Namespace: CORE

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]].

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
size2Optional parameter. If omitted, the command uses its internal default.

Minimal example

v = [10, 20, 30]
A = [[1, 2], [3, 4]]
PRINT v[1], A[1,0]

DIM

STATEMENTBATCH-FRIENDLY
Kind: Command   Category: Language keywords   Namespace: CORE

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]].

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
size2Optional parameter. If omitted, the command uses its internal default.

Minimal example

v = [10, 20, 30]
A = [[1, 2], [3, 4]]
PRINT v[1], A[1,0]

ELSE

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

ELSE

Alternative branch of an IF block.

Minimal example

IF CV.WIDTH(img) > 512 THEN
    PRINT "large image"
ELSE
    PRINT "small image"
ENDIF

ENDFUNCTION

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

ENDFUNCTION

Closes a FUNCTION block.

Minimal example

FUNCTION CONTRAST_SCORE(img)
    RETURN CV.STDDEV(img)
ENDFUNCTION

score = CONTRAST_SCORE(gray)

ENDIF

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

ENDIF

Closes the IF block.

Minimal example

IF CV.WIDTH(img) > 512 THEN
    PRINT "large image"
ELSE
    PRINT "small image"
ENDIF

ENDSUB

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

ENDSUB

Closes a SUB block.

Minimal example

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
ENDFUNCTION

ENDSWITCH

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

ENDSWITCH

Closes a SWITCH block.

Minimal example

SWITCH score
CASE 0 TO 30
    PRINT "low"
CASE 31 TO 70
    PRINT "medium"
CASE > 70
    PRINT "high"
DEFAULT
    PRINT "invalid"
ENDSWITCH

ENDTRY

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

ENDTRY

Closes a TRY/CATCH block.

Minimal example

TRY
    IO.LOAD "missing.png" AS img
CATCH err, line
    PRINT "Error at line "; line; ": "; err
ENDTRY

EXIT

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

EXIT

Terminates the current script cleanly. Useful in interactive scripts after a cancelled dialog or an explicit user choice.

Minimal example

path = GUI.GET_OPEN_FILE_NAME("Open image")
IF path = "" THEN
    EXIT
ENDIF

FALSE

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

FALSE

Boolean false constant.

Minimal example

FALSE

FOR

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

FOR 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.

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
STEPOptional parameter. If omitted, the command uses its internal default.

Minimal example

FOR i = 0 TO 9 STEP 1
    PRINT i
NEXT

FOR value IN samples
    PRINT value
NEXT

FUNCTION

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

FUNCTION 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.

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
param1First algorithm-specific tuning parameter.
param2Second algorithm-specific tuning parameter.
returnVarOptional parameter. If omitted, the command uses its internal default.

Minimal example

FUNCTION CONTRAST_SCORE(img)
    RETURN CV.STDDEV(img)
ENDFUNCTION

score = CONTRAST_SCORE(gray)

IF

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

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.

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
statementOptional parameter. If omitted, the command uses its internal default.

Minimal example

IF CV.WIDTH(img) > 512 THEN
    PRINT "large image"
ELSE
    PRINT "small image"
ENDIF

IF v < 0 THEN v = 0

IMAGE

KEYWORDBATCH-FRIENDLYIMAGE
Kind: Keyword   Category: Language keywords   Namespace: CORE

IMAGE

Logical type returned by TYPE(x) for single images.

Minimal example

IMAGE

IN

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

FOR 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.

Minimal example

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
NEXT

INCLUDE

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

INCLUDE "library.cvb"

Alias of USING. Includes another cvBasic source file before execution, with the same path resolution, nested include support and recursive cycle protection.

Minimal example

INCLUDE "lib/algebra_utils.cvb"

PRINT VEC2_NORM([3, 4])

LET

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

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.

Minimal example

A = [[1, 2], [3, 4]]
A[0,1] = 9
PRINT A[0,1]

NEXT

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

NEXT

Closes the FOR loop.

Minimal example

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
NEXT

NOT

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

NOT expr

Logical negation.

Minimal example

IF NOT CV.IS_STACK(img) AND CV.WIDTH(img) > 0 THEN
    PRINT "single image"
ENDIF

OR

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

expr OR expr

Logical OR operator.

Minimal example

IF NOT CV.IS_STACK(img) AND CV.WIDTH(img) > 0 THEN
    PRINT "single image"
ENDIF

PRINT

STATEMENTBATCH-FRIENDLY
Kind: Command   Category: Core statements   Namespace: CORE

PRINT expr1 [; expr2 ...] [, exprN ...]

Writes the provided values to the log output.

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
expr2Optional parameter. If omitted, the command uses its internal default.
exprNOptional parameter. If omitted, the command uses its internal default.

Minimal example

PRINT "Width="; CV.WIDTH(img); " Height="; CV.HEIGHT(img)

REM

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

REM text

Starts a BASIC-style comment. Text after REM is ignored when REM is used as a standalone token.

Minimal example

REM

RETURN

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

RETURN [expr]

Exits the current SUB or returns expr from the current FUNCTION.

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
exprOptional parameter. If omitted, the command uses its internal default.

Minimal example

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
ENDFUNCTION

STACK

KEYWORDBATCH-FRIENDLYSTACK / VIDEO
Kind: Keyword   Category: Language keywords   Namespace: CORE

STACK

Logical type returned by TYPE(x) for frame stacks.

Minimal example

STACK

STEP

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

FOR var = start TO end [STEP step]

Increment of the numeric FOR loop.

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
STEPOptional parameter. If omitted, the command uses its internal default.

Minimal example

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
NEXT

SUB

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

SUB name([param1 [, param2 ...]])

Starts a named subroutine block. The block is skipped during normal flow and executed only by CALL.

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
param1First algorithm-specific tuning parameter.
param2Second algorithm-specific tuning parameter.

Minimal example

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

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

SWITCH expression

Starts a multi-branch selection block. The expression is evaluated once and compared with each CASE value, range or numeric comparison.

Minimal example

SWITCH score
CASE 0 TO 30
    PRINT "low"
CASE 31 TO 70
    PRINT "medium"
CASE > 70
    PRINT "high"
DEFAULT
    PRINT "invalid"
ENDSWITCH

THEN

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

IF condition THEN [statement]

Separates the condition from the true branch. A statement after THEN creates a one-line IF.

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
statementOptional parameter. If omitted, the command uses its internal default.

Minimal example

IF CV.WIDTH(img) > 512 THEN
    PRINT "large image"
ELSE
    PRINT "small image"
ENDIF

TO

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

FOR var = start TO end [STEP step]

Specifies the final value of the FOR loop.

Optional parameters

Parameters enclosed in [...] may be omitted. Nested brackets mean that the later parameter is available only when the previous optional level is also supplied.

ParameterMeaning
STEPOptional parameter. If omitted, the command uses its internal default.

Minimal example

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
NEXT

TRUE

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

TRUE

Boolean true constant.

Minimal example

TRUE

TRY

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

TRY

Starts a protected block. Runtime errors raised before CATCH are intercepted instead of stopping the script.

Minimal example

TRY
    IO.LOAD "missing.png" AS img
CATCH err, line
    PRINT "Error at line "; line; ": "; err
ENDTRY

USING

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

USING "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.

Minimal example

USING "lib/image_quality.cvb"

score = CONTRAST_SCORE(img)

WEND

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

WEND

Closes the WHILE loop.

Minimal example

i = 0
WHILE i < 3
    PRINT i
    i = i + 1
WEND

WHILE

KEYWORDBATCH-FRIENDLY
Kind: Keyword   Category: Language keywords   Namespace: CORE

WHILE condition

Starts a conditional loop.

Minimal example

i = 0
WHILE i < 3
    PRINT i
    i = i + 1
WEND