Tuesday, May 26, 2009

Two IDE's are Better Than One

In my last article I showed how to use Programmer's Notepad with BC.exe (the QuickBASIC compiler). Some people might have gotten the impression I was trying to do away with the QuickBASIC IDE. That's just not true! I have chosen to see QuickBASIC as a programming language that happens to have an IDE. The QB IDE has a built-in help system and advanced debugging tools (tools that do not work in WindowsXP). It also has a cumbersome text editor that is difficult or impossible to use on many current computers. This is especially true for my laptop.

Luckily, the QuickBASIC IDE can be set to save and open QB projects as plain text. These plain text files can be opened, modified, and saved by modern text editors. Using a combination of QB.EXE and modern text editors, working in tandem, you can significantly increase productivity on newer computers. This is especially true for large, multi-file QB projects. Then there are advantages in terms of memory and performance, but I'll get into that some other day.

The previous article was an introduction to using Programmer's Notepad(PN) along with BC.EXE. In this article I will introduce the idea of using PN with QB.EXE.

With a BASIC file open in QB.EXE, select File>Save As
A new window will open
In the Format section, select the option marked Text - Readable by Other Programs and click OK. Save your BASIC file.

In PN, you can now open the very same BASIC file for editing.

There are many differences between the QB IDE and PN. PN can make organizing, editing, and compiling multifile QB projects easier. You can also have each file of a multiple module program open in its own tab. There are also some advanced features, including user tools and macros written in Python, which allow you to do things in PN that you cannot do in QB.EXE.

PN will not check your code as you write it the way QB does (I'll work on that later), but PN has autocomplete functionality. Just start typing and you will see a list of words that you might use.

Another cool feature is code folding. To get an idea of what code folding is, look at this code:
And now look at the same code after it's folded:
You see here a program with 141 lines of code can fit in a small space if it's all folded up. Each section of code can be folded or unfolded or all code can be folded or unfolded.
You may also notice that as you type, your text changes color. This is called syntax highlighting. It makes reading code easier. The words recognized by autocomplete and syntax highlighting can be adapted to suit your needs.

If you look around PN, you will find many more useful features. There are windows for projects, tags, and scripts. PN also allows users to create macros and user tools. Of all these features, we will just be looking at user tools in this article.

With your BASIC file open in PN, select Tools>Options and then make sure Tools is selected on the left. Press the Add button. Make the next window that opens look like this:
Make sure the path to QB.EXE is correct. Press OK and then OK again. Press your hotkeys to use the tool. You should now see your code opened in the QB IDE. You can use all the tools of the QB IDE (if you are on an older system) and save the file. When you go back to PN you will see this popup:
If you want to keep the changes you made to your code in the QB IDE, choose Yes. Your updated code will appear in PN.

If you would like to have QB.EXE interpret the code you are working on in PN, you can do that as well.

With your BASIC file open in PN, select Tools>Options and then make sure Tools is selected on the left. Press the Add button. Make the next window that opens look like this:

Again, make sure the path to QB.EXE is correct on your computer. Press OK and then OK again. Press your hotkeys to use the tool. You should now see your code interpreted by the QB IDE. If there are errors in your code, the IDE will let you know with a message like this:
If there are no errors your code will execute. When finished, your code will be opened in the IDE.

NOTE: If you do not want your interpreted program to exit to the QB IDE, make your code end with the keyword SYSTEM.

No comments: