External functions

Top 

 

You can call external functions that are in a DLL from the PLC-program. Doing this you declare a function (no function block) with PLC|New with exactly the same parameters as the external function. Within the function you call the external function with the key word EXTERNAL followed by the name of the DLL and the function name. Example:

 EXTERNAL trysimdll control

The capitalization of the function name has to be noted.

The function in the DLL has to follow the C-call-conventions, that means if you have written the DLL in pascal you will have to set the key word cdecl after the specification of the parameter. Bool, Byte, Char, Int(16-bit), Word(16-bit), DInt (32-bit), Dword(32-bit) and REAL(4 bytes) are only permitted as parameter types.

 

Please note that the naming of the data types in STEP®7, C and Pascal is not identical:

 

STEP7        

C

Pascal

bool

bool

boolean

char

char

char

byte

byte

byte

word

unsigned short

word

int

short

smallint

dword

unsigned long

dword

dint

long

integer

real

float

single

 

STEP®7 is a registered trademark of the Siemens AG.