Actually anything you want them to do, but specifically a Plugin works in concert with NPBuilder based on what type of Plugin it is.


For example if a Plugin is Type 1 which is accessable from the BScript Editor then it should serve some purpose which works in concert with the BScript Editor. A practical use for this type of Plugin would be to display some user interface where an end user can define some task or action they need to accomplish and then the Plugin would then generate BScript code which it can then pass back to the BScript Editor.  The Profile Editor which comes with NPBuilder is a good example of such a use.


If the Plugin is Type 2 which is accessable from the Code Blocks Editor then it makes sense to use it to read from the Code Block Editor the current Code Block program and from that parse it and generate source code for a specific programming language (ie. Visual Basic dot.net) and then put that code in the Windows Clipboard to be pasted into a code editor such as Visual Studio.


If the Plugin is Type 9 which is accessable from the Plugin Visual Designer dropdown menu then it could be used to scan the current form displayed in the Visual Designer and then generate source code for a new plugin for any programming language you require. This would be to generate a base template to start from and then copy it to the Windows Clipboard so it can be pasted into your programming language code editor.


To accomplish these tasks requires the plugin to be able to communicate with NPBuilder and either pass it data to use or to read data from it. NPBuilder has an API (and commands) which can be used by Plugins to accomplish this and NPBuilder can do a number of advanced tasks for your Plugin. So what can NPBuilder do for a Plugin ?


NPBuilder has four key API functions which a Plugin can call (best to use wrappers provided in include or header file). They are SetText, GetText, SetValue, GetValue. The Powerbasic include file provides wrapper functions for these API's which are:


NP_SetText

NP_GetText

NP_SetValue

NP_GetValue


For the rest of this discussion this topic will refer to these API functions as SetText, GetText, SetValue, GetValue instead of the wrapper names above, since header files for other languages may define the wrapper functions with slightly different names.


SetText and GetText work in concert together. Sometimes you need only Set the text of a control and that is it, but some times SetText may send a control a command and it will get a reply back using GetText. SetValue and GetValue are used much less and usually only for controls which need to set or return a numeric value.


The use of SetText and GetText depends upon the control type (ie. Text, Label, Button) or whether you call using a Pseudo ID (a system command). Controls are defined with a numeric ID number which is always a positive number. The Form has an ID of zero. Their are also Pseudo ID's which are not controls but a system command engine in NPBuilder which allows you to interface to NPBuilders own interface or even request an advanced UI task. Pseudo ID numbers are always a negative value and are predefined in the include (or header) file.


Some control types expect a Scripting language command be sent to it such as the Vector Graphic control or the OpenGL control. 


So what are some advanced things Plugin controls can do ?


OpenGL control can display 3D objects in 3D space and animate them, using the OpenGL Scripting language.

Vector Graphic control can display a 2D image which is a vector image defined using the Vector Graphics Macro language.

XMLTree control can load an XML file and display it as an XML Tree.


So what advanced UI tasks can be accomplishing using SetText and GetText with the Pseudo IDs ?


  • Retrieve the current list of devices available to connect to (ie. Commander module)
  • Open a selected Device
  • Close a selected Device
  • Send a Device a command
  • Display the Windows Open File Dialog and retrieve filename
  • Read a file into a Memory Buffer and retrieve it
  • Display a Dialog to Copy NPBuilder system runtime files (Commander HID DLL and BScript runtime DLL) to any folder
  • Replace (or Insert) code into the BScript code editor
  • Read current Code Block Program to parse it for code generation
  • Copy text to Windows Clipboard
  • Scan and Parse current Form in Plugin Visual Designer
  • Retrieve current BScript code in BScript code editor
  • Tell NPBuilder to close (exit) your Plugin Dialog


Future features may be added so the above may not be all inclusive.