View Full Version : Using Notepad++ as a code editor in D3

12-17-2017, 03:56 PM
I'm going to use this forum to post little projects I have devised using Hostaccess and D3. This is my first little project.

I use D3's UPDATE processor to edit code on a daily basis. I have configured the cursor/page keys using the Hostaccess Keyboard Mapping so as to mimic MS Word navigation functionality. I have also set the terminal width and height to 177x66 thus giving me a nice wide area to code in. Sometimes though, this is not enough, as the UPDATE processor's search/replace and paging functions are quite clumsy/clunky. There's no reverse search for example and when you page back and forth through the code, the cursor always goes to the top of the page rather than staying where it was on the screen. Editing large programs can become quite cumbersome, particularly if you have to skip back and forth a lot.

It was for the above reasons I decided to write a little utility program to export the program from D3 to Windows and use Notepad++ to edit the code, then "suck" it back into D3. It took a couple of days to get working as there were some issues with the Hostaccess code itself which didn't work properly. Together with Roguewave Support, I was able to get it working though. I finally settled on the PIX.WIN.RUN command to start Notepad++ after several unsuccessful tries with other methods.

The export process uses another little utility program I wrote called SEND. This program "sends" the PICK item to the C:\TEMP folder with an extension of .BAS, .TXT, or .HTM based on a specified option. This same program also "gets" the same file and imports it back into D3 in the place whence it came, overwriting the old version. There is no versioning built in as yet simply because I have not needed it.

Because I am using the PIX.WIN.RUN command to execute Notepad++, I need to specify the full path to where Notepadd++ is installed. You'll easily spot this in the program. As the SEND utility changes the name of the item being exported, I have to specify this as the filename to be edited by Notepad++, otherwise, it just wouldn't work. This is done by making an assumption based on the programming standards I use: Anything edited in files BP, SR, FBP, FSR, or UTILS is a BASIC program and thus the Windows file should have an extension of .BAS, anything edited in file W3HTML is an HTML item and should have a .HTML extension, and anything else should just be a text file and have an extension of .TXT. Once this is done I can call PIX.WIN.RUN to kick of Notepad++ with the exported item. I should mention here that I have set up a FlashBasic Language in Notepad++ for syntax highlighting. It works reasonably well, better than none in the UPDATE processor...

Bringing the edited code back was a little clunky in implementation and I haven't yet included a check to see if the code was actually modified before recompiling any BASIC code. I just took it for granted it WAS changed and recompiled it. Doesn't really matter either way as unchanged code will still function the same way once recompiled.

I had to use PIX.WIN.RUNNING to check if the instance of Notepad++ with the exported file was still running. If it was, then sleep for a bit and check again later until it was no longer being edited. this turned out to be a little difficult as PIX.WIN.RUNNING doesn't use the window application's program name, e.g. notepade++.exe, rather, it uses APPLICATION name. As it turns out, 99% of the time this is what appears in the window's title bar. So, in the end, it was fairly easy to work out for Notepad++. Once it was detected to no longer be running, it is assumed the edited file has been closed and is ready to import back to D3. I use my "SEND" utility in "reverse" as I already have the commands/parameters from the original export and all I need to do is to add a "G" to the command's option to "get" the file back from windows and import into its original location in D3. Easy.

The source code for the two programs is available in the attachments.

Note the use of the windows path "C:\TEMP" for the export. I chose to use this folder rather than "%TEMP%" as it is much quicker to locate and type in Windows Explorer. It is also easily accessible by the user as it would have the same permissions as the user. If the folder does not already exist, then just create it. If necessary change the permissions to full access for everyone, but shouldn't be needed.

Note also the lack of error checking and comments in the NP utility. I developed these utilities quickly to fill a void and they work 99% of the time as is. I'll update the code if I ever come across any errors worthwhile of attention.

I hope this code/implementation is useful to someone. Feel free to post updates, suggestions etc.


01-24-2018, 01:46 PM
Hi Walter,
Wow, exactly what I seek. What an immense amount of time and aggravation you've just saved me. Thank you so much for sharing your effort!

11-25-2019, 01:53 PM
Hi Walter,
Wow, exactly what I seek. What an immense amount of time and aggravation you've just saved me. Thank you so much for sharing your effort!

You're very welcome. I'm glad someone is getting good use from it.