Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>CRBasic VSCode Support - Campbell Scientific, Inc.New to Visual Studio Code? Get it now.
CRBasic VSCode Support - Campbell Scientific, Inc.

CRBasic VSCode Support - Campbell Scientific, Inc.

Gary Roberts

|
1,214 installs
| (2) | Free
CRBasic programming language support for Visual Studio Code and Campbell Scientific data loggers
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

CRBasic language support extension

VS Marketplace Version VS Marketplace Installs VS Marketplace Rating

This Visual Studio Code extension gives you full language support for CRBasic, the language you use to program Campbell Scientific CR and GRANITE series dataloggers. It provides syntax highlighting, IntelliSense, signature help, hover documentation, code navigation, diagnostics, quick fixes, and a browsable instruction panel.

Supported dataloggers

The extension provides model-specific support for these Campbell Scientific dataloggers:

Datalogger Series Description
CR1000X and CR1000Xe CR Series Measurement and control datalogger with analog and digital input and output
CR6 CR Series Measurement and control datalogger with universal terminals
CR300 CR Series Compact measurement and control datalogger
CR310 CR Series A CR300 with Wi-Fi and Ethernet communication
CR350 CR Series Compact datalogger with extended measurement capabilities
GRANITE6 GRANITE Series High-performance measurement and control data acquisition system
GRANITE9 GRANITE Series High-performance data acquisition system with no built-in measurement
GRANITE10 GRANITE Series High-performance data acquisition system with no built-in measurement

IntelliSense, hover documentation, the Instructions panel, and the documentation links all filter by the datalogger model you select, so you see only what your hardware supports.

Installation

From the VS Code Marketplace

  1. Open VS Code.
  2. Go to the Extensions view (Ctrl+Shift+X or Cmd+Shift+X).
  3. Search for CRBasic.
  4. Select Install on CRBasic VSCode Support - Campbell Scientific, Inc.

From a .vsix file

  1. Download the .vsix file.
  2. In VS Code, open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P).
  3. Run Extensions: Install from VSIX....
  4. Select the .vsix file that you downloaded.

Getting started

  1. Open or create a CRBasic file with any supported extension: .crb, .cr1x, .cr300, .cr6, or .dld.
  2. Select your datalogger model. Go to File > Preferences > Settings and search for crbasic.dataloggerModel. You can also let the extension detect the model from the first line of your file.
  3. Start typing to see IntelliSense suggestions, or browse the Instructions panel in the Activity Bar.
  4. Create a new program from a template with File > New File... > CRBasic Program.

Features

Syntax highlighting

The extension highlights every CRBasic keyword, instruction, operator, data type, and comment. Semantic highlighting also gives public variables, private variables, constants, data tables, and functions their own colors, based on how you declared them.

IntelliSense and code completion

  • Automatic completion for more than 475 CRBasic instructions and keywords.
  • Model-specific filtering. You see only the instructions that your datalogger model supports.
  • Context-aware suggestions. For example, output processing instructions appear only inside a DataTable block.
  • Cross-file completions. Variables and constants from Included files appear in the suggestion list.
  • Completions grouped by category, each with detailed documentation.
  • Snippets with tab stops, so you can enter code quickly.
  • Parameter pick lists. When you type inside a function call, the extension suggests valid values from the official DEF files, such as voltage ranges, thermocouple types, and data types.

Signature help

Inline parameter hints for every CRBasic function. Each hint shows:

  • The function signature with all of its parameters.
  • Parameter descriptions with pick-list options and default values from the official DEF files, such as voltage ranges, thermocouple types, and data types.
  • The current parameter, highlighted as you type.

Hover documentation

Rest the pointer on any CRBasic keyword or function to see:

  • The function signature.
  • Detailed parameter information, with valid options and default values from the official DEF files.
  • Links to the official Campbell Scientific documentation for your model.

The documentation links point to the help site for the model you configured.

Code navigation

Action Shortcut Description
Go to Definition F12 Go to the declaration of a variable, constant, table, or subroutine. Works across Included files.
Find All References Shift+F12 Find every use of a variable, table, or subroutine. Searches Included files.
Rename Symbol F2 Rename a variable, constant, data table, subroutine, or function in the current file and in every Included file.
Include file navigation Ctrl+select Select an Include "filename" path to open that file.
Breadcrumbs Breadcrumb bar Shows the path to the current scope as you navigate, such as BeginProg > Scan.
CodeLens Above declarations Shows a reference count, such as "3 references", above each variable, constant, table, and subroutine. Counts include references in Included files.
Document Outline CRBasic sidebar Shows every declaration, grouped by kind, with type details and support for Included files.

Code diagnostics

The extension validates your program as you type. It checks for:

  • Mismatched Begin and End pairs, such as BeginProg and EndProg, If and EndIf, or For and Next.
  • Mismatched preprocessor directives, such as #If and #EndIf.
  • Code blocks that you never close.
  • End statements with no matching opener.
  • Variables, constants, data tables, subroutines, and functions that you declare but never use. These appear as dimmed text, and the check reads Included files too.
  • Duplicate declarations of a variable, constant, data table, or subroutine.
  • Missing Include files. The extension warns you when a path points to a file that doesn't exist.
  • Wrong argument counts in calls to built-in functions, whether you pass too many or too few.
  • Mismatched literal types in function arguments. For example, a string literal where a number belongs, or a literal value where a variable reference is required.

Quick fixes

The extension offers code actions that fix common problems:

  • Add a missing EndIf to an If statement.
  • Add a missing EndTable to a DataTable block.
  • Add a missing Next to a For loop.
  • Add a missing EndSub to a subroutine.
  • Add a missing #EndIf to a preprocessor conditional.

Automatic capitalization and variable name matching

The extension corrects the case of CRBasic identifiers as you type:

  • Keywords and instructions. Every built-in instruction changes to its standard PascalCase form. For example, beginprog becomes BeginProg, and scan becomes Scan.
  • Logical operators. and becomes AND, or becomes OR, not becomes NOT, xor becomes XOR, mod becomes MOD, imp becomes IMP, and intdv becomes INTDV.
  • Data types. float becomes Float, long becomes Long, double becomes Double, boolean becomes Boolean, and string becomes String.
  • Other keywords. as becomes As, true becomes True, false becomes False, and nan becomes NAN.
  • Variable name matching. Variable, constant, data table, and subroutine names change to match the case of their original declaration.
  • The extension skips text inside string literals and comments.
  • To turn this off, use crbasic.enableAutoCaseCorrection.

Document formatting

To reformat the indentation of your whole program, run Format Document (Shift+Alt+F). The formatter:

  • Indents every block structure, including BeginProg, Scan, If/Else/EndIf, For/Next, Sub/EndSub, DataTable, Select Case, While/Wend, and Do/Loop.
  • Handles preprocessor blocks (#If, #ElseIf, #Else, and #EndIf).
  • Recognizes single-line If x Then y statements, so it doesn't indent them by mistake.
  • Corrects keyword and variable name case when crbasic.enableAutoCaseCorrection is on.
  • Follows the tab size and the spaces-or-tabs setting of your editor.
  • Removes trailing spaces but keeps blank lines.
  • Ignores keywords inside string literals.

Compile a program (Windows only)

You can compile your CRBasic program with the official Campbell Scientific compiler from inside VS Code:

  • Select the play button in the editor title bar, open the shortcut menu and select CRBasic: Compile Program, use the Command Palette, or press Ctrl+F6.
  • The extension picks the compiler that matches the datalogger model it detects.
  • Compiler errors and warnings appear as VS Code diagnostics with the correct line numbers.
  • The full compiler output appears in the CRBasic Compiler output channel.
  • The extension saves the file before it compiles.
  • You need the Campbell Scientific compilers, which come with LoggerNet or with the standalone CRBasic Editor.
  • If you installed the compilers somewhere other than the default location, set the path in crbasic.compilerDirectory.

Code folding

You can collapse and expand these blocks:

  • Scan and NextScan loops.
  • DataTable and EndTable blocks.
  • If, Then, and EndIf conditionals.
  • For and Next loops.
  • Sub and EndSub subroutines.
  • SlowSequence and EndSequence blocks.

Document Outline panel

A color-coded tree in the CRBasic sidebar that shows every declaration in your program, grouped by kind, with detailed type information:

  • The groups are Public Variables (blue), Dim Variables (gray), Constants (orange), Data Tables (teal), and Subroutines & Functions (purple).
  • Each variable shows its data type (Float, Long, Boolean, String, or Double), its array dimensions, such as Float(14), and its string length, such as String *200.
  • Each constant shows its assigned value, such as = 10.0.
  • The tree includes declarations from Included files and labels them with the name of the source file.
  • Select any declaration to go to its source line. The extension opens external files for you.
  • The tree refreshes as you edit.
  • Empty groups stay hidden.
  • You can change the symbol colors in workbench.colorCustomizations. See Configuration.

Data Tables panel

A sidebar panel that shows the data output structure of your program at a glance:

  • Lists every DataTable block with its output interval and units.
  • Expand a table to see all of its output fields, each with its field name, processing type (Average, Sample, Totalize, Maximum, Minimum, StdDev, or WindVector), and data type (FP2 or IEEE4).
  • Handles the multiple fields that WindVector produces, which range from two to four depending on OutputOpt.
  • Honors FieldNames overrides that rename the default field names.
  • Select any table or field to go to its source line.
  • The panel refreshes as you edit.

Instruction Help panel

A sidebar panel that shows live documentation for the CRBasic instruction under your cursor:

  • Updates as you move the cursor from one instruction to another.
  • Shows the instruction signature, description, parameters with their types, and example code.
  • A Pin button locks the current instruction and stops cursor tracking.
  • An Insert button inserts the instruction at the cursor, with snippet tab stops.
  • A Wizard button opens the Parameter Wizard, which guides you through building the instruction.
  • Links to the official Campbell Scientific documentation for the datalogger model you selected.
  • Also updates when you select an instruction in the Instructions panel above it.

Parameter Wizard

A webview panel for building a CRBasic instruction call with every parameter visible at once:

  • Opens next to the editor and shows each parameter as a numbered field in a form.
  • A parameter with known options shows a menu of valid values from the official DEF files, such as voltage ranges, thermocouple types, and data types. Each menu also has a text box for a custom value.
  • A parameter that expects a variable shows the variables you declared in your program in its menu, including Public, Dim, and Const symbols and symbols from Included files.
  • A parameter that expects a data table shows the DataTable names you declared in its menu.
  • A free-form parameter shows a text box with the default value from the DEF file already filled in.
  • A live preview of the finished instruction updates as you fill in the fields.
  • The wizard removes optional trailing parameters that you leave empty.
  • To insert the instruction, select Insert or press Ctrl+Enter or Cmd+Enter. To cancel, press Esc.
  • To open the wizard, select the wand icon next to an instruction in the Instructions panel, select the Wizard button in the Instruction Help panel, or run CRBasic: Parameter Wizard in the Command Palette.

Instructions panel

A sidebar panel for browsing every CRBasic instruction. To open it, select the CRBasic icon in the Activity Bar.

  • An alphabetical list of more than 475 instructions, each with a category label.
  • A search box that filters instructions by name.
  • A category filter that shows only one type of instruction, such as Measurement, Math, or Data Tables.
  • Filtering by datalogger model, so you see only the instructions that your configured logger supports.
  • Select the wand button to open the Parameter Wizard and build the instruction step by step.
  • Select the + button to insert an instruction at the cursor, with snippet tab stops.
  • Select the ? button to open the Campbell Scientific documentation for that instruction.
  • The panel appears only when you edit a CRBasic file.

New program template

To start a new CRBasic program quickly:

  • Use File > New File... > CRBasic Program, or run CRBasic: New Program in the Command Palette.
  • The extension asks which datalogger model you want to target.
  • It then inserts a standard program template with the correct first-line datalogger declaration.

Automatic model detection

The extension reads the first line of a CRBasic file, such as 'CR1000X Series Datalogger, to detect the target model. The detected model overrides the global setting for that file, so each file can target a different datalogger without changing your settings.

Configuration

To open these settings, go to File > Preferences > Settings.

Setting Default Description
crbasic.dataloggerModel CR1000X Selects your Campbell Scientific datalogger model. This setting controls which instructions appear in completions, hover help, the Instructions panel, and the documentation links. The options are CR1000X, CR6, CR300, CR310, CR350, GRANITE6, GRANITE9, and GRANITE10.
crbasic.enableDiagnostics true Turns real-time syntax validation and diagnostics on or off.
crbasic.enableCodeActions true Turns quick fix suggestions for common errors on or off.
crbasic.enableUnusedVariableDetection true Turns detection of declared but unused variables, constants, data tables, and subroutines on or off.
crbasic.enableDuplicateDeclarationDetection true Turns detection of duplicate variable, constant, data table, and subroutine declarations on or off.
crbasic.enableCodeLens true Shows or hides the reference counts above declarations.
crbasic.enableSemanticHighlighting true Turns semantic highlighting on or off. This gives variables, constants, tables, and functions their own colors.
crbasic.enableArgumentCountValidation true Turns detection of wrong argument counts in built-in function calls on or off.
crbasic.enableArgumentTypeValidation true Turns detection of mismatched literal types in built-in function arguments on or off.
crbasic.enableFormatting true Turns the built-in document formatter on or off. The formatter runs with Format Document (Shift+Alt+F).
crbasic.enableAutoCaseCorrection true Corrects the case of keywords, instructions, operators, and declared variable names as you type and when you run Format Document.
crbasic.compilerDirectory C:\Campbellsci\Lib\Compilers The path to the folder that holds the Campbell Scientific compiler programs. LoggerNet and the standalone CRBasic Editor both install them. Windows only.

Document Outline colors

To change the symbol colors in the Document Outline panel, edit workbench.colorCustomizations in your VS Code settings.

Color ID Default (dark) Description
crbasic.symbolVariable #75BEFF Public variable symbols
crbasic.symbolDimVariable #9E9E9E Private Dim variable symbols
crbasic.symbolConstant #EE9D28 Constant symbols
crbasic.symbolDataTable #4EC9B0 Data table symbols
crbasic.symbolSubroutine #B180D7 Subroutine symbols

Keyboard shortcuts

Shortcut Action
Ctrl+Space or Cmd+Space Show IntelliSense suggestions
Ctrl+Shift+Space or Cmd+Shift+Space Show signature help
F12 Go to Definition
Shift+F12 Find All References
Shift+Alt+F Format Document, which reformats the indentation
Ctrl+' Comment Block, which adds ' to the selected lines
Ctrl+Shift+' Uncomment Block, which removes ' from the selected lines
Ctrl+F6 Compile Program (Windows only)
Ctrl+Shift+O or Cmd+Shift+O Go to Symbol in the document outline
Ctrl+Shift+P or Cmd+Shift+P Command Palette, where you can search for CRBasic commands

Online CRBasic help

You can find the CRBasic help for each Campbell Scientific datalogger here:

  • CR1000X and CR1000Xe
  • CR6
  • CR300 and CR310
  • CR350
  • GRANITE6
  • GRANITE9
  • GRANITE10

Supported file extensions

.crb, .cr1x, .cr300, .cr6, and .dld

Known issues

  • The IntelliSense help text isn't finished for every CRBasic instruction. Coverage grows with each release.
  • A few of the newest datalogger instructions are still missing, though coverage keeps growing. The extension now covers more than 475 instructions.
  • The extension skips block validation for If/EndIf and For/Next in files that contain preprocessor conditionals (#If), because conditional compilation makes block matching unreliable.

Requirements

VS Code 1.100.0 or later.

Current maintainers

  • Gary Roberts (Daiwalkr)
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft