Navigation:  »No topics above this level«

Getting Started

Print this Topic Previous pageReturn to chapter overviewNext page

Files you need

Note: For the purposes of this documentation, DPlot and DPlot Jr are used interchangeably unless there are clear differences, and will in most cases be referred to simply as "DPlot".

DPLOT.EXE or DPLOTJR.EXE. Whether your application will use DPLOTLIB to create plots within DPlot as a standalone application or display plots created by DPlot within a window of your own application, you will need either the full version of DPlot or DPlot Jr. The DPLOTLIB DLL simply acts as an interface between your program and DPlot; it does not perform any graphics operations by itself. You can get the setup program for DPlot Jr from the DPlot web site. The direct link to the DPlot Jr setup program is http://www.dplot.com/dplotjr_setup.exe. Licensed users of the full version of DPlot should sign up for the mailing list to ensure that you have the latest version of the program.

What's the difference? DPlot Jr is free and may be distributed without royalty payments or any other fees. However, it lacks many of the features of the full version. In particular you cannot open a file with DPlot Jr, either within the program or programmatically. DPlot Jr also lacks many of the data generation and analysis features of the full version; e.g. FFT, curve fitting, generating a curve or surface from an equation, etc. For many applications, though, you'll find DPlot Jr adequate for your needs. The full version of DPlot cannot be distributed to end users of your application without a developer license or a bulk license for your expected user-base. Contact us for more information on a developer license and/or bulk-licensing options for the full version.

NOTE: This version of DPLOTLIB requires version 1.97 or later of DPlot. Earlier versions will not work properly with all functions. Check the version number with the About command on the Help menu. If you do not have the minimum version number, you can get them by following the instructions above.

 

DPLOTLIB.DLL or DPLOTLIB64.DLL. This library handles all of the communication between your application and DPlot. These DLL's are included with the distributions; all files related to the DLL are installed to the \dplotlib folder below DPlot. The default installation folder is c:\Program Files\DPlotJr. If you have already downloaded and installed DPlot Jr, you do not need any additional files. You can also get the DPLOTLIB files from http://www.dplot.com/lib/dplotlib.zip. Unzip this file to the folder of your choice, making sure that "Use folder names" is checked so that you preserve the folder structure within the ZIP file.

 

Interface files. These files describe the calling convention and argument list to your compiler.
oVisual Basic 6: global.bas in the \btest folder. Add this file to your project with Project>Add Module.
oVisual Basic .NET: global.vb in the various \vbnet project folders. Add this file to your project with Project>Add Module.
oPowerBasic: dplot.inc in the \pb folder. Include in your project with #INCLUDE "dplot.inc".
oFreeBASIC: fb-dplotlib.bi in the \freebasic folder. Include in your source with #INCLUDE "fb-dplotlib.bi".
oC (all currently supported compilers: Microsoft Visual C, Borland, LCC, GCC): #include dplot.h, found in the \c folder for 32-bit applications and \64bit\common for 64-bit applications.
oC#: Class dplot.cs, located in the various example program folders. Add a class to your project. Open any of the dplot.cs files. Select the entire file, copy, then paste into your new class, replacing the entire file. Be sure to change to "namespace" to that of your project.
oFORTRAN: dplot.fi in the project folder for each supported FORTRAN. Note that these files are, in almost all cases, not interchangeable between various FORTRAN compilers.

 

 

Import library. Irrelevant for Visual Basic, Visual Basic .NET, and C#. For other environments, if you will be statically linking to the DLL (as opposed to using LoadLibrary and GetProcAddress at runtime) you will need to link to the appropriate import library. Otherwise you will get "unresolved external" errors on DPLOTLIB functions when linking. For the currently supported languages and compilers, the import library dplotlib.lib can be found in the project folder for your language. For example if using Microsoft Visual C, use the file \c\msvc\dplotlib.lib. For 64-bit C programs, use \64bit\common\dplotlib64.lib.

Other Compilers/Languages

Many 32-bit compilers will link properly with the import library dplotlib.lib found in the \c\msvc folder. Others may require that you build an import library from the compiled DLL using a compiler-specific tool. If you search your compiler's documentation for "import library" you will likely find the information necessary to build an import library from dplotlib.dll. Requests for support of additional languages/compilers will at the very least be considered; if you have such a request contact the author at support@dplot.com.

For languages that support it (C, for example), you can alternatively resolve all DPLOTLIB references at runtime rather than linking to an import library by using LoadLibrary and GetProcAddress. A thorough explanation of the technique is beyond the scope of this documentation. The gcc example programs use this technique; see the end of the header file dplot.h in the \c folder for more information.

Where does DPLOTLIB.DLL/DPLOTLIB64.DLL go?

Wherever you want, as long as your program can find it. Many Windows applications install DLLs to the Windows System folder. Although this will work (your application, or more correctly Windows, will find the DLL with no special effort), we strongly advise against doing this with either DLL. Although you can certainly ensure that you do not overwrite new copies of the DLL with an old version, there is no way to guarantee that another developer will be as well-behaved. When searching for DLLs Windows will always look in the application folder (the folder where your compiled executable resides) first. This is true whether statically linking to a DLL using an import library, or dynamically linking at runtime using a call to LoadLibrary. So the simplest thing to do is copy dplotlib.dll or dplotlib64.dll to the folder where your executable will reside. This will work correctly for all compiled executables, regardless of the language or compiler used by your program.

For running your application within the development environment (for example Visual Basic 6, VB.NET, or C#) you will need to take an extra step. That is simply because the "application folder" in this case is not the folder where your project resides, but the folder where your development tools reside. But, as luck would have it, the second place Windows looks for DLLs is in the "working directory", which you can control programmatically.The VB 6, VB.NET, and C# examples are distributed with a subroutine DPlot_FindDPLOTLIB which looks in the registry for the location of dplotlib.dll and, if found, switches the working directory to that folder.

VB 6:

Public Sub DPlot_FindDPLOTLIB()

Dim hKey As Long

Dim hLib As Long

Dim intZeroPos As Long

Dim lpcbData As Long

Dim result As Long

Dim path As String

Dim strBuffer As String

 

hLib = LoadLibrary("dplotlib.dll")

If hLib <> 0 Then

' If LoadLibrary finds the DLL, then VB will too and there's

' no need to fool with changing the working directory.

FreeLibrary (hLib)

Exit Sub

End If

' This key SHOULD have been set by the installation of DPlot Jr and/or DPlot.

' Or, of course, by your own program's setup routine.

result = RegOpenKey(HKEY_CURRENT_USER, "Software\DPLOT\DPLOTLIB\Folder", hKey)

If result = ERROR_SUCCESS Then

' If this fails, all hope is lost :-)

' The first DPLOTLIB call will result in a runtime error.

result = RegQueryValueEx(hKey, "", 0&, REG_SZ, ByVal 0&, lpcbData)

If result = ERROR_SUCCESS Then

strBuffer = String(lpcbData, " ")

result = RegQueryValueEx(hKey, "", 0&, 0&, ByVal strBuffer, lpcbData)

intZeroPos = InStr(path, Chr$(0))

If intZeroPos > 0 Then

path = Left$(strBuffer, intZeroPos - 1)

Else

path = strBuffer

End If

ChDrive path

ChDir path

End If

result = RegCloseKey(hKey)

End If

End Sub

VB.NET:

Public Sub DPlot_FindDPLOTLIB()

' Find DPLOTLIB.DLL.

Dim key As Microsoft.Win32.RegistryKey

Dim path As String

Dim hLib As IntPtr

 

hLib = LoadLibrary("dplotlib.dll")

If hLib <> 0 Then

' If LoadLibrary finds the DLL, then so will VB.NET, so there's

' no need to look in the registry or change the current

' directory

FreeLibrary(hLib)

Exit Sub

End If

 

key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\DPLOT\\DPLOTLIB\\Folder")

path = key.GetValue("").ToString()

key.Close()

If Len(path) > 0 Then

System.Environment.CurrentDirectory = path

End If

End Sub

C#:

public static void DPlot_FindDPLOTLIB()

{

// Find DPLOTLIB.DLL

int hLib;

string path;

 

hLib = LoadLibraryA("dplotlib.dll");

if (hLib != 0)

{

/* If LoadLibrary finds it, then so will C#. So there's no

* need to check the registry or set the current directory. */

FreeLibrary(hLib);

return;

}

 

Microsoft.Win32.RegistryKey key =

Microsoft.Win32.Registry.CurrentUser.OpenSubKey(

"Software\\DPLOT\\DPLOTLIB\\Folder");

if (key != null)

{

path = key.GetValue("").ToString();

key.Close();

System.Environment.CurrentDirectory = path;

}

}

The 64-bit code is identical, with the exception that it attempts to load dplotlib64.dll and, if that fails, looks in the registry under HKCU\Software\DPLOT\DPLOTLIB64\Folder. DPlot_FindDPLOTLIB() is called by the Form_Load event in each of the examples. If successful, your application will have no trouble finding the DLL whether your application is run as a compiled executable or within the respective programming environment. The registry keys HKEY_CURRENT_USER\Software\DPLOT\DPLOTLIB\Folder and HKEY_CURRENT_USER\Software\DPLOT\DPLOTLIB64\Folder are set by the installation programs for DPlot Jr and the full version of DPlot. If you move either DLL around on your system then you will need to modify that key if you want to find the DLL from within these environments.

Note that the above is not necessary for compiled executables, so there is no need to modify the registry on your end users' systems unless you are distributing source code.

Regardless of what method you use to help Windows find the DLL, do NOT be tempted to use hard-wired paths like C:\TEMP, even if done only temporarily. That sort of thing is easily forgotten about, and you don't want end users complaining to you about non-existant file folders.

What's next?

We strongly suggest taking a look at the example programs (described on the following page) before diving in with your own application. The simplest examples generate data and pass that data to DPlot using the DPlot_Plot function. Those are the VB6 btest.vbp project in \btest, the VB.NET project in \vbnet\Project1.NET, the ctest.c C example located in \c, and the 64-bit examples in \64bit\ctest1, \64bit\csharp1, and \64bit\vbnet1. (All FORTRAN examples perform these same basic functions).

 

 


Page url: http://www.dplot.com/lib/index.htm?getting_started.htm