Instruction manual

AMPDIO DRIVERS
Page 82
8) The menu bar will now appear in the Form1 design window. Click on the 'Exit' item to bring up
the code window for the mnuExit_Click() subroutine. At runtime, this routine will be called
whenever the 'Exit' menu is selected.
9) Type the following lines into the mnuExit_Click() subroutine, to un-registers the board from the
DLL as the program closes.
Dim e As Short
e = FreeBoard( hBoard )
if e <> OK then Call ReportError( e )
End If
These steps will create the shell of a VB application that can now be run. The program at this stage
does nothing more than register a board with the DLL on start-up, and free that board on exit.
Section 6.4 describes the library functions available. Where arguments to functions are described
as pointers, the address of a user-declared variable is required. Visual Basic normally does this
anyway. The function declarations in DIO_TC.BAS uses the ‘ByVal’ prefix for all function
arguments that are not passed as pointers. For example, function TCgetCount requires a pointer to
a variable declared as long, into which the count value result will be placed. A typical VB code
example for displaying the Z1 Counter 0 count value would be as follows:
Dim count As Long ' declare count as long
i = TCgetCount( h, Z1, 0, count )' count now contains new
Text1.Text = Str$( count ) ' value
6.3.3 Delphi 3.0 Onwards
To open one of the Delphi example projects provided with the DLL, from within Borland Delphi 3.0
select 'File|Open ' and select one of the .DPR project files provided in the EX_DELPH subdirectory
of the AmpDIO software directory. The project window will now appear on the desktop. Double-
click on any file in the project to view the source code, or select Run to run the program.
To create your own Delphi program from scratch, perform the following steps:
1) From within Borland, select 'File|New Application’. A new project window will appear with an
empty Form1.
2) Select View Project Manager and add DIO_TC.PAS from the EX_DELPH subdirectory of the
AmpDIO software directory:
DIO_TC.PAS - DLL declarations and global constants
3) Double-click on the empty Form1 design window to bring up the code window for the
Form_Load() subroutine. At runtime, this routine will get called when the program first starts
up.
4) Type the following lines into the Form_Load() subroutine:
var
i:smallint;
cardtype:smallint;
begin
// find a board using registerBoardEx which
// doesn't need to know base address etc etc
i := 0;
repeat
hboard := registerBoardEx(i);