The BASCOM IDE

Top  Previous  Next

bascom-ide-sections

 

 

The IDE screen is divided in a number of sections.

- On the top you find the menu and menu bar

- When a file is opened, a TAB bar is visible. You can select a file by clicking on it's TAB.

- The IDE is an MDI editor which means that you can have multiple windows open and visible at the same time. The most screen space you get when the window is maximized. If you maximize one window, all windows will be maximized. The screen image shows the editor window in maximized state.

- At the left you will find the Code Explorer , Properties and Events windows. These are dockable windows. This means that you can position the window in a dockable area. Dockable areas are placed at the bottom, left and right.

When multiple windows are docked to the same area, TABS will be shown. You can select a window by clicking at the TAB.

- At the right you will find the Project Manager and the Chip PinOut viewer.

- At the bottom there is an Information window and a Find in Files result window.

 

You can drag and drop dockable windows between dockable areas. You can also undock the window by dragging and dropping outside the dock area.

When you close a dockable window you can display it from the View menu.

 

In order to occupy less screen space you can also make the dock windows appear/disappear automatically. Notice the pin at the to right of the dockable window. When you click it, the window will change state.

The following screen image shows the same editor window with the dockable windows hidden. Now they use a fraction of the screen space.

By moving the mouse to the TAB, the window will appear.

 

bascomide-dockauto

 

As long at the window has the focus it will remain visible. When you move the focus to the editor window for example, the dockable window will disappear again. You can see at the orientation of the pin, in which state the dockable window is.

 

Code Explorer

code-explorer

 

The Code Explorer can be used to find variables, functions, types, labels, constants, declarations and errors in your program.

Just double click on a value and the editor will set the focus to the item.

 

Assembler

Each assembler block or line will be shown under the Assembler branch.

 

Constants

Constants are shown under the Constants branch. Both constants from the definition file and your code will be shown.

A different image is used so you can see the difference. When you select a constant from the definition file, the focus will be set to the first line of the editor.

 

Declarations

Both sub and function declarations are shown under the declarations branch. Selecting a declaration will set the focus to the declaration in your code.

 

Errors

All errors are shown under the Errors branch. Selecting an error will jump to the error. Each error will have a red error wave too so you can identify the error quickly.

On the bottom , just above the info window you will find a small message bar. This message bar contains a smiley. When there is an error it will be red. Double clicking the smiley will result in a jump to the next error. When there is no error, the smiley will be yellow and smile :-)

 

Functions

Functions and sub procedures are shown under the Functions Branch. Selecting will set the focus to the function/sub implementation.

 

Labels

Labels are shown under the Labels branch. Since labels are now unique to the function, you can use the same label name in different functions/procedures. When a label is placed inside a function/sub, an extra branch will be shown with the function/sub name. In the screen image above you can see this at the 'Testlabel'.

 

Variables

Variables are shown under the Variables branch. All registers from the definition file are also shown. This because registers from the def file are treated as bytes (or words).  As you can see at the screen image, the BASCOM variables are shown different than the variables from the definition file.

Some variables can be generated by the definition file. For example the _day variable is a result of the CONFIG CLOCK command in the example code. When you select this variable you will jump to the CONFIG CLOCK definition.

Since a variable can be used in the main program but the same name is allowed in a function or procedure, duplicates are placed under a branch with the function/sub name.

 

 

Drag and Drop

You can drag and drop items (variables, constants, etc) into your code.

 

The code explorer is updated automatically.

 

Filter

All the values in the code explorer can be filtered. When you set the focus to the code explorer and you type a text phrase, all items that start with this fragment will be shown. All other items will be hidden. The caption of the code explorer will show the text phrase.

 

 

Events

IDE-events

 

When your source code contains the #autocode and #endautococode block, the Properties and Events windows are filled. Without the #autocode block, these windows will remain empty.

The code between #autocode and #endautocode is maintained automatically by the IDE.

That is, when you select a sub routine in the Events window, the IDE will insert matching code into the editor.

This code is inserted in the #autocode block.

 

When you type a CONFIG statement inside the #autocode block, it will shown up in the Events and Properties windows automatically.

 

In this example this is how the block looks like :

#autocode

On INT0 isr_int0 Nosave

On INT1 isr_int1

#endautocode

 

The NOSAVE option was added manual.

 

The Events window will not create sub routines, you can select existing sub routines.

Alls available interrupts are shown automatically. This info is loaded from the definition file.

 

 

Properties

ide-properties

 

The properties window shows all possible configuration options. When an options is not configured, it will not be shown.

Like the Events window, the values are only loaded and shown when the #autocode block is available in your code.

For old projects you need to insert it in order to use the Properties window.

All values are maintained automatically. CONFIG options and values are shown, and when you select a value, the matching CONFIG line will be inserted/adjusted into the editor.

 

The available options/properties will depend on the selected micro processor, or actually on the chosen definition file, which you do with the $regfile directive.

 

To remove a value, you can delete the line in the editor or in the Properties editor.

 

 

Project Manager

IDE-pm

 

The BASCOM-IDE uses projects as a container for your project files.

Each project can contain any number of project files. Your project needs a least one BASCOM-BASIC source file.

Depending on the extension of the file you add, the file will be placed under a branch.

- Source Files : BAS

- Graphics : BMP, PNG, GIF, JPG

- PDF Files : PDF

- Misc Files : TXT, HTM, HTML , all other files.

 

Only BAS and TXT files can be edited in the editor. All other previous mentioned files can be viewed. File with an unsupported extension can not bed editor nor viewed.

 

The Project Manager allows you to organize the files.

By default the Project Manager window is docked at the right of the screen.

 

The files are shown in a tree. All BASCOM-BASIC source files you add, are placed under the 'Source Files' branch.

All files are shown relative to the project file (bpj). If a file is in the same folder as the main project you will see only it's filename without the path. When the file is in a different folder, the path info will be shown. ..\ means that the file is located one folder above the project file.

 

When you double click a file, it will be opened if it was not opened yet. If the file was opened, the proper TAB will be selected.

 

Main File

Because your project can have multiple files, you need to inform the IDE which project is the main project that must be compiled. This file is shown in blue.

While you can add files, it does not mean that the file is used automatically.

In BASCOM, you work with one source file. You can split functionality into separate files. With the $INCLUDE directive you can include this files in your code. So you can make a file with all constants, one with module declarations and modules, etc.

These files have to be included like normally with the $INCLUDE directive.

The first file under the 'Source Files' is always the main project file that will be compiled.

 

A pop up menu allows you to set a source file as the main file.

 

You can add an existing file to the project or remove a file from the project.

noticeWhen you remove a file from the project, you have the option to remove it from the disk as well.

 

 

Status Bar

The status bar contains information and buttons.

At the left you will find a record button. When you press it, it will become red and all keys you enter into the editor are recorded.

When you click the record button again, the recording will stop. When you click the play button, it will play back the macro.

 

Beside the play back button you will fine the line and cursor location.

The smiley is an error indicator. If there are no errors it will smile (yellow) and when there is an error, it will be unhappy (red).

Clicking the smiley will set focus to the first error.

Clicking again will set focus to the next error.

 

The file name is also shown in the status bar, and you can view the editor status. When you modified the text, it will show 'Modified'. When a file is read only, it will show 'Read Only'.

At the right you will find the CAPS, INSERT and NUM lock status.

 

 

Info Window

The information window will show messages from the IDE.

When the message is related to a file or position, it will also show this file and position. In such a case you can jump to the location by double clicking the line.

 

 

The Editor

The editor has a lot of special features.

 

ide-editor

 

The editor will show a yellow bar when a line is edited. When you save the file, these yellow indicators will become green.

When the file is reloaded these indicators disappear.

 

 

Code Outlining

As you can see at the editor screen shot above, the editor will outline all blocks. A block is for example a Do.. Loop construction.

 

 

Code Folding

All blocks can be collapsed into a single line of code. This allows you to have a good overview of the program.

Use F11 to collapse or expand a block.

When a block is collapsed, the marker will show a plus [+].

 

ide-collapse

In this example, you can see that the block is collapsed. Now the entire block uses only 1 line in the editor!

Another indication that text is collapsed are the dots placed after the line [...]

When you hover the mouse above these dots, the hint will show the underlying code.

If you click the dots, the block will be expanded. But only the matching block is expanded.

In order to make all the lines visible of the block, press F11.

 

 

Dynamic Error Checking

This option will check your code while you type. Each time you have edited/inserted/removed a line, the IDE will check the project. If an error is found, it will be added to the Errors branch in the Code Explorer, but you will also see a red marker under the error source.

ide-error

When you move the mouse cursor over the error you will see a short error description. There are a big number of errors that can be found. But not all errors can be determined. Only a real project compilation can show these errors. For example when you use some ASM to jump to a routine, there is no check if the jump is within range. Only at assembling stage this can be determined.

 

 

Auto Case

The editor will reformat the line after it is modified. It will also change the case of reserved words.

The variables, constants, functions, labels, you define can have a mixed case.

For example : Dim MyVariableWithMixedCase

The editor will leave this case as defined.

When you use the variable in your code and you enter it in small case, it will be changed in the defined case.

This is a good way to see if you typed an existing variable (or constant, sub, label, etc). If it exists, it will be reformatted with the defined case.

 

 

Auto Complete

This option will complete code in a number of situations. For example when you type :  If A=1 Then

And you enter, the editor will insert the matching 'End If' automatically at the proper indention level.

If you type endif, the editor will change it into End If.

If you type a sub/function declaration like : Declare Sub Test(myparam as Byte)

The editor will insert the matching procedure automatically.

 

 

Info

When you hover the mouse above a variable or constant, a hint will be shown depending on the data.

For constants the value will be shown. For variables the data type will be shown.

For functions the definition will be shown.

 

 

Proper Indention

The proper indention is an option of the editor. It can indent the entire source code. When you use indention, your source code is better readable.

 

Compare this :

Sub SomeSub()

If A=1 Then

Do

Loop

End If

End Sub

 

With:

Sub SomeSub()

 If A=1 Then

    Do

    Loop

 End If

End Sub

 

Here each block is indented.

 

 

Named Bookmarks

You can give each of the eight possible bookmarks a name. Just move the cursor over the bookmark number and press the right mouse button. Now you can type a description of the bookmark. All bookmarks are saved with your project.

The description will be shown in the bookmark menu's. It will also be shown when you move the mouse over the bookmark number.

 

 

Split Editor

ide-split editor

 

The editor can be split in two. This way you can view some code in the upper editor and modify some code in the bottom editor.

 

 

Code Help

The code help is maybe the most convenient option of the editor.

You get code help automatic in some cases, and in other cases you can call it by pressing CTRL+SPACE

Code help will offer statements, functions, procedures, variables, constants, etc. depending on the command and cursor position.

 

For example, when you press CTRL+SPACE at the begin of a line, you will find this list :

 

codehelp

The example above shows statements and variables(from the definition file in this case). This because you can start a line with a statement, function or variable. Constants are not in the list because you can not start a line with a constant.

So the content varies with the context.

 

When you type , say DE, the list will be filtered.

codehelp-filter

Choose the option you need and press enter to select it. It will be inserted into the editor automatically.

 

You can also start typing and then press CTRL+SPACE.

For example : PR<CTRL+SPACE>

 

This will show :

codehelp-3

 

When you press CTRL+SPACE after the PRINT statement, you will get a list with constants, variables and functions.

 

When you type a statement like :   A= A + <CTRL+SPACE>  , you will also get a list.

After a GOTO you would get a list with labels.

After a ON you will get a list with all interrupts.

After a CONFIG you will get a list with all config options for the selected chip.

Each parameter of the CONFIG will lists the possible options also.

 

Inside Assembler scope, you will get different codehelp.

For example, this is the list you get inside an assembler block :

codehelp-asm

And depending on the assembler command, you will get a different list.

For LDI that supports only the upper registers for example you will get :

codehelp-asm-ldi

 

 

Syntax Highlight

This IDE gives you more color control for the syntax elements.

You can set the reserved words, strings, comment, identifiers, integer, float, ASM, user sub/function, constants from the definition and hardware registers from the definition file. You can also set bold and italic attributes.

With syntax coloring you can identify the elements more quickly.

 

 

Jump to Definition

You can jump to a definition by clicking a variable, constant, or other element and pressing CTRL.

The history arrows will take you back to the location you jumped from.

 

 

Hungarian Notation

The editor supports automatic Hungarian notation. Hungarian notation is where you add a prefix for a variable name. This way you can see at the prefix the data type. For example :  Dim myvar as byte

This will not make clear in your project what kind of data type is used. But if you use a prefix, say 'b' : bMyvar  then you can tell at this prefix the data type. In Options you can specify a prefix for each data type.

Now when you type :  dim myvar as byte , the editor will change this into :  dim bmyvar as byte

The prefix is automatically added. When you prefix the variable yourself, the editor will not change it.

Of course you can turn this automatic notation on and off in the options.

 

 

Dead Code

The editor can show dead code. Dead code are variables that are dimensioned but never used. Or code that is never called.

 

dead-code

In this example, the variable b_b3 is not used. And the function notused() is not used. Both are shown in grey.