Adept Scientific - English
The world's best software and hardware for research, science and engineering.
flag arrow
clearclear

 Adept Store | register Join My Adept | Flags  
Adept Scientific | Amor Way | Letchworth Garden City | Herts | SG6 1ZA | Tel: +44 (0)1462 480055  
UKdedksvnofi
Home
Products
Training
Events
 Buy Online
Downloads
Academic Discounts
Support
My Adept
International |  About Us |  Adept Scientific Blog |  Contact Us |  Press Room |  Jobs
Adept Scientific on Facebook Adept Scientific on Twitter Adept Scientific on YouBube Adept Scientific on LinkedIn


The Next Steps

• Contact the DADiSP Team
• Buy DADiSP Now
• View DADiSP Pricing
• Download a Brochure
• Request a Brochure
• Download a Demo
• Request a Demo
• Meet Our Team

Learn More

DADiSP Home
DADiSP Application Builder
Top 10 Features
DADiSP Graph Gallery
DADiSP and ActiveX
DADiSP SPL vs MATLAB
Real World user stories
Online Tutorials
Rave Reviews
System Requirements

Latest Information

What's New in DADiSP
New Functions
Using DADiSP with Excel
Additional Software Modules

Service & Support

Patches & Downloads
DADiSP FAQ's
Search the Knowledge Base
Technical Support request

DADiSP

DADiSP and ActiveX

ActiveX is a broad term that generally refers to a Microsoft binary standard for sharing code and data between separate programs or "components". The actual protocol is specified by the Component Object Model (COM). COM has undergone many upgrades and enhancements since its original introduction as Object Linking and Embedding (OLE).

ActiveX Automation


One important feature of COM is Automation. Automation allows a "client" program to control a "server" or component program just as if the component functionality was built into the client. For example, DADiSP can fully control Microsoft Word, placing a DADiSP Worksheet into a document and printing the results all from within DADiSP. Likewise, a Visual Basic program can hand off data to DADiSP for processing without DADiSP ever being visible to the user. In this way, DADiSP acts as a powerful data analysis library for any program that supports Automation.

ActiveX components generally expose three basic constructs:
  • Properties
  • Events
  • Methods
Properties represent the various settings of the component such as color, font, size, etc.

Events are notifications the component makes to the client program. Some possible events are mouse was clicked, canvas was sized, button was pushed, etc. After receipt of the notification, the client can respond appropriately.

Methods are functions the client program can direct the component to execute.

DADiSP Automation Server


DADiSP as an ActiveX server or component supports several extremely powerful methods, including:
  • Getdata(window or variable)
  • Putdata(window or variable, data)
  • Execute("command string")
Getdata retrieves data from a DADiSP Window or variable to the client. For example, here's a Visual Basic code fragment that obtains the series in W2 of a DADiSP Worksheet into a Visual Basic variable:



Dim DADiSP As Object ''' Connect to DADiSP Set DADiSP = CreateObject("DADiSP.Application") VbVar = DADiSP.Getdata("W2")


In this example, Visual Basic acts as the "client" and DADiSP the ActiveX "server".

We declare DADiSP as an ActiveX object with the

Dim DADiSP As Object

declaration. Visual Basic establishes a connection to DADiSP with the

Set DADiSP = CreateObject("DADiSP.Application")

statement. The connection is made by checking the Registry for ActiveX components and capabilities. For faster ActiveX communication, DADiSP also provides a COM "Type Library" (dadisp.tlb) that provides in depth information on the ActiveX capabilities offered by DADiSP. Finally,

VbVar = DADiSP.Getdata("W2")

copies the series or table in W2 into the Visual Basic array VbVar. ActiveX data transfers are quite flexible and efficient. DADiSP transparently supports multi-column data using the COM standard SafeArray. Byte, Integer, Float, and Double scalar values are also supported.

Here's a code fragment that generates a Visual Basic array and then transfers the array to DADiSP.



''' Create VB Data Array For i = 0 To 999 VBData(i) = Rnd() Next i ''' Connect to DADiSP Set DADiSP = CreateObject("DADiSP.Application") ''' Put Array to DADiSP Call DADiSP.PutData("W1", VBData)


You can also "get" or "put" data to a DADiSP variable. For example:



Call DADiSP.PutData("DArray", VBData) Call DADiSP.PutData("DNum", 12.3) Vb1 = DADiSP.GetData("DArray") Vb2 = DADiSP.GetData("DNum")


Here we transfer an array and a scalar to the DADiSP variables DArray and DNum and then retrieve the data from DADiSP back to Visual Basic.

The Execute method is perhaps the most powerful. Execute allows any DADiSP command, including SPL routines, built-in functions, macros and command files to be executed from ActiveX. For example, the following code fragment creates a 2 Window Worksheet and generates a 1000 point random series in DADiSP:



''' Create a 2 Window Worksheet (unconditional) Call DADiSP.Execute("NewWorksheet(2, 0)") ''' Generate Random Data Call DADiSP.Execute("Grand(1000,.01)")


Because Execute accepts any valid DADiSP command as input, all the features, functions and capabilities of DADiSP are available to any program that supports ActiveX Automation.

Now for a full example of ActiveX with Visual Basic controlling DADiSP. We'll use each of the above methods to 1) create data in VB, 2) transfer it to DADiSP, 3) use DADiSP to process the data and 4) retrieve the processed result from DADiSP.



Sub DSPTest() Dim DADiSP As Object Dim VBData(1000) As Double ''' Create VB Data Array For i = 0 To 999 VBData(i) = Rnd() Next i ''' Connect to DADiSP Set DADiSP = CreateObject("DADiSP.Application") ''' Create a 2 Window Worksheet (unconditional) Call DADiSP.Execute("NewWorksheet(2, 0)") ''' Put Array to DADiSP Call DADiSP.PutData("W1", VBData) ''' Label W1 Call DADiSP.Execute("Label('Data from VB')") ''' Moveto W2 Call DADiSP.Execute("Moveto(W2)") ''' Calculate Power Spectrum Call DADiSP.Execute("PSD(Hamming(W1))") ''' Add Y Log and Grids Call DADiSP.Execute("SetyLog(1);GridSol;GridHV") ''' Show DADiSP DADiSP.Visible = 1 ''' Get PSD from DADiSP newdata = DADiSP.GetData("W2") End Sub


To make DADiSP appear on the screen, we set the "visibility" property with:

DADiSP.Visible = 1

You could also use the DADiSP SETVISIBLE function:

DADiSP.Execute("SetVisible(1)")



DADiSP Automation Client


So far, we've shown examples of controlling DADiSP from Visual Basic. In this case, Visual Basic is the "client" and DADiSP acts as the ActiveX "server". However, DADiSP can also function as an ActiveX client to control and make use of the features of ActiveX servers such as Excel, Word, database programs or data acquisition drivers.

The DADiSP SPL syntax for ActiveX is very similar to the Visual Basic syntax mentioned above. For example, to connect to an ActiveX object, you use the CreateObject function. Properties can be set and retrieved with standard variable assignments and methods executed with the "dot" syntax. For example, the following SPL code fragment connects to Word and makes it visible:



/* start and display Word using ActiveX */ ShowWord() { local word; // start Word word = CreateObject("Word.Application"); // let's see it! word.Visible = 1; }


DADiSP can access any function exposed by the ActiveX Automation server. For example, Word has a very elaborate ActiveX hierarchy, consisting of Documents, Ranges, Tables and a host of other objects all accessible to DADiSP.

Finally, the full SPL example below demonstrates the use of these objects to create and copy a DADiSP Worksheet to a Word document.




// SPL Code: DADiSP to MS Word ActiveX calls msw() { local word, doc; // new 2 Window worksheet if (newworksheet(2) == 0) return; // generate noisy sine in W1 gnorm(1000,.01) * 0.1 + gsin(1000,.01); // set units to Volts setvunits("V"); // add a nice label label("Noisy Sinewave"); // moveto W2 moveto(w2); // set log scales setxlog(1); setylog(1); // calculate the PSD psd(w1); // copy worksheet into clipboard copyworksheet(); // start Word word = CreateObject("Word.Application"); // get "Document" object doc = word.Documents; // Add a new Document and get range object range = doc.Add().Range(); // paste worksheet as Enhanced Metafile word.Selection.PasteSpecial(0, 0, 0, 0, 9); // let's see it! word.Visible = 1; }


In conclusion, ActiveX is a very powerful, standardized means of sharing the capabilities of separate programs in a flexible and robust manner. The SPL\ActiveX subdirectory included with your DADiSP distribution provides several additional examples of using ActiveX with DADiSP.



Ready to buy?

Upgrade to the latest version of DADiSP from v2002/v6
Add to shopping basket
£ 575.00
Upgrade to the latest version of DADiSP from v5
Add to shopping basket
£ 750.00
Upgrade to the latest version of DADiSP from v4.1
Add to shopping basket
£ 895.00
DADiSP for Windows 7/9x/2000/NT/XP/Vista
Add to shopping basket
£ 1,640.00
Click here for more upgrade options.

Featured Downloads

DADiSP 6.5 - Browser & 15-Day Licence for MS Windows 9x 2000 NT XP Vista
DADiSP Industry Application Packs
DADiSP Brochure
DADiSP Getting Started Tutorial

Product Reviews

"DADiSP makes it possible for an engineer to hit the button to turn the program on at the end of the day, walk out of here, then come in the morning and find the work all done."
Rich Bond, Ford Heavy Truck

"DADiSP makes this kind of analysis very easy to do, so that I only have to worry about the science, not the programming."
Dr. Dan Davison, University of Houston

Latest News

DADiSP/WAV – Wav Audio module updated
DADiSP 6.5
Spreadsheet designed specifically for technical data analysis
DSP Development Corporation announces DADiSP® 6.5
"The next time you turn on the TV and see a Winston Cup race
adept

Top of the Page

Popular Links: ChemDraw | ChemOffice | Data Acquisition | Data Analysis | EndNote | Maple | MapleSim | Mathcad | MathType | Quality Analyst | Reference Manager | VisSim

EU ePrivacy Directive | Our Privacy and Terms and Conditions Statement
All Trademarks Recognised. Copyright © 2013, Adept Scientific plc.
Site designed and maintained by Lyndon Ash

Adept Scientific | Amor Way | Letchworth Garden City | Herts | SG6 1ZA | Tel: +44 (0)1462 480055