M Web Magazine Issue 001 (Dec 5, 1996 to Mar 4, 1997)

The Library

If you would like to send in your M-related code, simply attach a description to it, zip it up and send it to us.
The description should list the files in the archive, installation notes, what the program does and copyright information. Please clarify if your submission is shareware / trialware / freeware and other information you see appropriate.
When e-mailing information for this section please set the subject line to MWM The Library. The e-mail address is chribonn@softhome.net.

 Danny Wijnschenk, Sales Engineer at InterSystems Belgium mailed in an archive that runs on Visual M databases.

Included in the archive is code that implements a non-visual component for the Borland Delphi programming system. This enables Delphi code to access Open M databases and to execute Open M program code. Also included is a "Delphi and Visual M FAQ".

The archive (and FAQ) may be downloaded from here.


Delphi and Visual M FAQ

by Danny Wijnschenk (InterSystems Corp.)

Last edited : 29 October 1996

Q1. Can Delphi and Visual M work together ?

Yes, and by combining a fast (true compiler), object oriented visual RAD tool like Delphi in combination with a fast database like Open M, you get double power.

Q2. Ok, How ?

Delphi works with components, VCL or others (like OCX). The Visual M OCX works with Visual M version 7, and Delphi 2.01. Previous versions can only work by using the DLL file.

You can make a component yourself in Delphi by using the DLL file of Visual M :

- copy visualm.vbx to visualm.dll for 16-bit Delphi 1.x
or
- copy visualm.ocx to visualm32.ddll for 32-bit Delphi 2.0

(in the windows\system directory)

Then, you can create a new component in Delphi, or take the example component M or the example that the company GlobalWare build. This component really is just a interface to the dll file: you can define the component's properties, event code or methods.

Again, the example from GlobalWare or the M component has all this already implemented.

Once you took-created-got the component, you have to install it into Delphi.

Q3. How do I install it?

In Windows 95, Delphi 2.0 (32-bit) :

- Make sure you installed at least the thin Open M client on you PC and you have copied the file \windows\system\visualm.ocx to \windows\system\visualm32.dll.

- Install the Delphi-Visual M component into the bin directory of Delphi (usually C:\Program Files\Borland\Delphi 2.0\Bin)
Copy the .DCU and the .RES file (the .PAS file is the source code) You do not have to put them in the bin directory, you can also make a new directory for your components.

- Before doing anything in Delphi, it is always recommended to make a copy of the file cmplib32.dcl; if anything goes wrong when installing components, this file will contain your old state. (This is a general advice when installing any component in Delphi).

- Launch Delphi 2.0, go to the menu option 'Component', 'Install...' Click on the 'Add' button, then on the 'Browse' button,
Click on the component :


- Mengine.pas if you use the component from GLobalWare,
- M.pas if you use my component

Click on the 'Open' button, and on 'Ok'. Delphi will re-compile all the components on its component palette. Depending on the component, it will be installed in

- a new tab called 'GlobalWare' for the GlobalWare component
- the 'Data Access' tab for my component

Q4. When recompiling the palette, Delphi returns with an error message and the whole palette is empty.

When compilation of the M component fails, it usually means that Delphi did not find the file VisualM32.dll; make sure you copied it from the visualm.ocx file, in the windows\system directory.


Copy the backup file of the Delphi components back to cmplib32.dcl.

Q5. Everything is installed, but how do I actually use Visual M with Delphi?

Once the component is installed onto the component palette, you can double-click it, so it will appear on your form.

You can change properties of the object at design time in the object properties box, or in your Pascal code (properties and methods).

Q6 Huh?

Ok, let's take an example :

Launch Delphi, and double click on the M component, so it will appear on your form:

For the GlobalWare component, it is installed in the GlobalWare tab, it will have a default name MEngine1.

For my component, it will be in the Data Access tab, and the default name will be M1.

Put two edit boxes and a button on you form.

Double-click on the button; the Pascal editor will appear:

an empty procedure will be already there:

procedure TForm1.Button1Click(Sender : TObject);
begin

end;

Add some pascal code like this:

M1.Code := Edit1.Text;
M1.Execflag := 1;
Edit2.Text := M1.Value;

It will look like this:

procedure TForm1.Button1Click(Sender : TObject);
begin
M1.Code := Edit1.Text;
M1.Execflag := 1;
Edit2.Text := M1.Value;
end;

Run the program (click on the green button, or choose Run in the menu).

You can enter some M code in the first edit box (e.g. =$zv), and after you click on the button, the return value will appear in the second edit box.

Q7. What are the properties/methods I can use in the already made components?

GlobalWare

properties :

Code
Name
NSpace
P0 .. P9
Tag
Timeout
Value

run-time properties :

Errorname
Errornumber

methods :

execute (will execute the code, e.g. MEngine1.Execute;)


My Code

properties :

Execflag (currently only M1.Execflag := 1; same as M1.execute)
Code
NSpace
P0..P9
PDelim
PList
Tag
Timeout
Value

run-time properties :

Errorname
Errornumber

methods :

execute
run(m-code) (will do the same as setting first the code, and then the
execute method, e.g. M1.Run('s P0=$ZV');

Q8. Can I use the MDesktop from within Delphi?

No, it is only available for VB.

Q9. Is there a way to speed-up my development in Delphi-Visual M?

Yes, you can create new components that inherit from existing ones, and add m-aware functionality to it.

For example, you can create a new MEdit component which inherits from the standard Edit component, but will also have a pattern match property. This property will contain valid M-pattern matching syntax and will do the validation in M.

Or, you can create a MCombobox or a MListbox that only need the property nspace and Globalref to be filled in, and that already contain all the logic of doing the $order or getting the data into the list.

I have an example of both objects, look for yourself, and create your own M-aware tools!


If you have more questions on this, or want to download examples, please contact:

Danny Wijnschenk
Sales Engineer Belgium
InterSystems

Tel. +32 16 53 76 82
Fax. +32 16 53 52 75

email : Belgium@intersys.com

Enjoy Delphi and Visual M !

Pass on our Web Address!

E&OE

Next Page

Up/TOC

Tell a Friend

 

1