Editing Code With External Editor Like Notepad++


Recommended Posts

I have dabbled a bit with Notepad++, from http://notepad-plus-plus.org/

 

It is a popular free, open-source code editor.  It stores a list of commands and other things related to programming, and will highlight them in color. It has presets for a number of languages, and allows you to create your own.

 

I wonder if it is viable to add the possibility of integrating such a code editor into DAQFactory.  I.e. as a option in addition to editing in a new window.  I would love to have a way to make it easier for me to find my errors, and color coding commands and other types of objects are one way to do that.

 

The motivation for this, is that it allows you to add a powerful coding utility without having to embed the full code for it in DAQFactory.  Of course, a special language setting file would have to be created for Notepad++. I have tried it myself, but for some reason I am not understanding how it is supposed to work, and cannot create a new one.

 

Ideally, I would love to see my own user variables somehow able to pop-up or be found, but I don't know if that is possible in Notepad++.  In DAQFactory it does not work well.  Sometimes it had double letters at the beginning after I select one of the items, and most of the time, it will not scroll down the list to the next choice.  Perhaps if you can interface with an existing editor, you can bypass all the coding to make it work well in your program.

 

 I am not saying that Notepad++ is the only viable option for this. I know there are other ones out there as open-source.

 

-Joe

Link to comment
Share on other sites

Notepad++ is just a wrapper for the scintilla editor which as it happens is the exact editor in use in DAQFactory sequences, so technically your request is already in place.  I'd be interested in hearing how our editor could be improved.  Remember, unlike many compiled languages, errors aren't really obvious to the editor until the script is run, so highlighting errors is a bit of challenge in a tool like DAQFactory.

 

That all said, expression edit boxes are not scintilla and exhibit some of the problems you mentioned (double letters in particular).  We need to look to perhaps using the script editor in edit boxes to solve these problems.

Link to comment
Share on other sites

The main feature I wish the editor had, is in regards to showing declared variables.  I don't know if the scintilla editor supports that possibility.  

 

However, I think it does support colors for reserved words, comments, text in quotes, and for numerical values and expressions.  Which, even if it can't detect when a variable is declared, with everything else having a color, only variables should be left.  And as I mentioned above, ideally it would color any declared variables their own color, so you can see at a glance if you correctly typed the variable's name.

 

I see that your editor only supports a few color categories.  Comments are maroon, brackets and parenthesis are blue, and everything else is green.  Even reserved words do not have a color assigned just to them.

 

You may also know that a fair percentage of men are color blind to some extent.  Though, that is not true for me, I am sure others would appreciate the ability to choose the colors.

 

-Joe

Link to comment
Share on other sites

You can change the colors from File - Preferences.  As for the rest, we'll look at offering more options.  Maybe you can post a suggestion in the Feature Request section.  Note that determining variable declaration is tough for a number of reasons, including most importantly that just because a variable is not declared at the time you are editing doesn't mean you have an error.  You may have just not run the script that declares it yet.  Its a lot easier to do this sort of thing in a language like C++ that compiles everything at once so its easy for the IDE to tell what exists and doesn't (well, its not easy, but it's at least possible).  DAQFactory is what I like to call a "live" environment, so its not always clear what is a typo and what is simply a symbol that you haven't gotten around to creating yet. 

Link to comment
Share on other sites

I imagine you can also see all the code internally somehow.  But, I realize this may not be able to be shown to the editor.

 

Regarding color settings, I had found the TOOLS/CUSTOMIZE, and didn't realize there were other settings under FILES/PREFERENCES. Though I should have known to look there.

 

Perhaps an alternative to coloring variables, is to create a separate window to list the variables.  It would have to search all the code in the program, and monitor the one you are currently editing for any declaration of variables.  Then, list the global variables, and the local variables that are in the code currently being edited. Clicking on one of the variables will paste the variable into where your cursor is located.

 

That made me think of another option.  If  it is possible to extract a list of variables, might it be possible to dynamically update the list of key words?

 

And yet another idea is to suggest to the user that he begin all his variables with a certain character such as GV for Global Variable, or LV for Local Variable.  That both would help keep track of them, but you could define that prefix as a delimiter to color code the variables.  I just tried this, but didn't come up with a good combination.  The problem was how to end the delimiter.  A space would not work as a delimiter.  Though, the user might end with a special character. But that may be getting to be too much.  I think I was pushing the idea to even suggest the GV or LV prefix.

 

I am just throwing out ideas.  But I will write the idea of coloring the reserved words as a separate suggestion thread.

Link to comment
Share on other sites

Not sure what you mean by the first sentence.  Script is somewhat isolated in DAQFactory, and common things like variables only exist once the script executes.

 

The problem with a list of variables, especially a dynamic list is that it takes a lot of processor power to keep up to date.  Adding components to the workspace was a big worry for the same reason.  It was only recently added because we felt that processors were finally fast enough, and even then if I remember correctly we provided a way to turn it off.  That said, many people continue to use what we consider the deprecated feature of V channels solely for this reason.

 

As for naming, what you describe is called hungarian notation, or at least close to that, and its been around for ages.  You are welcome to use it.  I certainly do to some extent.  In C++, where I use very few, if any, global variables, I add a g prefix, and I follow the MFC convention of adding m_ for member variables and C for classes.  In older versions of DAQFactory we required all strings to start with str (and also required var. in front), but removed that once we added variable declaration which is much cleaner.

 

Ideas are always good!

Link to comment
Share on other sites

By, "I imagine you can also see all the code internally somehow."  That was just a total guess on my part.  Though, obviously, you must be able to examine the scripts in your own program at some point. Otherwise you would not be able to . Perhaps such a step would occur only if you choose to edit a script in a separate window, and also accepted that all logging and other activities would be paused.

 

-Joe

Link to comment
Share on other sites

  • 2 weeks later...

I am on version 5.90 build 2152. The preferences screen does not save the chosen colors for code display.

 

Also, I will mention that Notepad++ has a number of features that are not implemented in DAQFactory's internal code editor.  So, I would still prefer to use Notepad++. I know you can export a .scr file, and then perhaps edit the code using that file in Notepad++.  Then, the obvious next step would be to import it back into DAQFactory.  But, I cannot see how. The file type choices for opening a file are .ctl, .ctl, and *.   Note that .ctl is listed twice and .scr is not there at all.  I tried opening a .scr using the * option, but that generates an error message, "Unable to load document..."  Is it possible that the .scr importing was accidentally removed?

 

-Joe

Link to comment
Share on other sites

One more thing I forgot to add to the prior message.  Assuming you do have a way to import .scr files, what language should I choose in Notepad++ to properly color the code?  If any existing language is not a good choice, can you provide one customized for your language?

 

-Joe

Link to comment
Share on other sites

There is no importing feature at this time.  The export was a quick solution for customers that really needed to find code, not as a way to use an external editor.  We are looking at better ways to allow for the use of external editors, or at least external files, but you would not be able to colorize if you use an external editor as that is done internally.  What features do you wish the DAQFactory editor had?

Link to comment
Share on other sites

Choose colors. [The internal editor does not allow you to choose the colors.  Though perhaps that is just a temporary bug in the preferences window.]

 

When you double-click a word, all instances of that word will highlight. Helpful to see the various instances of a variable.

 

Colorize a pair of parentheses. [ DAQFactory will bold them, but that occasionally does not work, and it highlights a letter, and not the parenthesis ]

 

Automatic indenting (via a plug-in)

 

Spell check.

 

There also seems to be a powerful macro feature.  I have not investigated it, but it occurs to me that this may allow for new commands like showing a list of declared variables, including local ones along with the name of the script they are associated with.  Personally, I would not want to learn their macro language to create any features, but perhaps your own company would do this for your own internal use, and make it available to users.  If DAQFactory's language was significantly like an existing language, then this may not be an issue, and existing macros could be used.

 

-Joe

Link to comment
Share on other sites

I will add another feature I can do in an external editor if I could export/import the .scr file.  A global search and replace of a variable name to rename it. As it is, you can only search and replace inside of that particular script.

 

-Joe

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.