NS Basic Hi-Res programming on the Pocket PC

One of the great things about the latest versions of NS Basic CE for Microsoft Pocket PCs is the ability to make programs hi-res aware. This means that you can write a program that can take full advantage of high resolution screens, such as the 640x480 VGA screens on many recent PDAs. However, to do that you need to build the program in the development environment on a desktop PC. That's a bit of a problem if you like to do some coding on the Pocket PC, or even when making amendments and debugging on the road. However, here's a way to allow your NS Basic code to run on a Pocket PC in hi-res using just three lines of code!

The first thing to do is go to the NS Basic development environment on a desktop PC and create a new formless project, perhaps called nsbhires for instance. Next, enter the three lines of code below into the code box.

Dim nsbtorun

nsbtorun = Left(CurrentPath, Len(CurrentPath)-3) & "nsb"

Chain nsbtorun,False

Now, in the properties pallette, set the 'Hi-Res Aware' property to 'True', as shown in Figure 1. You can also set other properties, such as your own icon file, if you wish, but what we've done so far is all that's truly needed. Now, just build your program to get an exe file with the same name you gave your project (you can ignore all the other files, we only need the exe). Now, copy that exe to your Pocket PC in the same folder that the NS Basic program you want to run in hi-res is stored, and rename the exe file to have the same file name (but keeping the exe extension). For instance, if your NS Basic program is called myhrprog.nsb, make the exe file myhrprog.exe. In fact, if you're using the default Microsoft file manager to rename your exe file life is even easier: it doesn't show the file extension.

Hi-Res setting in NSB CE.

Figure 1. Setting Hi-Res awareness.

Having done that, you can now run and edit your NS Basic program as usual, or you can run it in hi-res by clicking on the exe file in the file manager (so using your own icon for the exe file can help here). This gives you the best of both worlds and makes it easy to test your code to make sure it works on both hi-res and lo-res screens. If you wonder how it works, basically our new program uses its own file name to find the NS Basic program, by changing the exe extension to nsb. Then it loads and runs the nsb file as if it were part of its own program code. That also means you can make copies of the exe file for use with a number of NS Basic programs on your Pocket PC, without changing our three lines of code. And that's all there is to it!