Macro Language Reference > Macros > System > event
  
event
Description
The event macro is only useful in PTC ALD OCX where communication between PTC ALD and the enclosing application is required.
 
Example 229. Pass events from APP
You can pass your own events from APP, as the example below shows:
event 555 1024
 
Example 230. Automatic macros with events in scripts
This advanced example is executed by a template's autoexec script and carries out the following conditional actions:
If v21812 (the script line number) changes, increase the variable _AX_P_ and send the comment event 600 with the variable value as its parameter.
If v1818 (the script name) changes, increases the variables _AX_S_ and send the comment event 601 with the variable value as its parameter.
automac 1,"v21812",0,"(^_AX_P_++):(event 601,^_AX_P_^)",2;
2,"v1818",0,"(^_AX_S_++):(event 600,^_AX_S_^)",2
Adventtest.exe (the sample wrapper program delivered with APP OCX builds) displays the event number and the event parameter it receives from APP at the bottom left of the window; for example, event 600,1 would show 600 in the first field and 1 in the second.
 
Pre APP version 2.3, the number of received events is not displayed so the only way to see, on screen, consecutive events with identical numbers is to change their parameters. Hence the slightly unusual sample seen here.
Syntax
event event_number:n event_param:n
event_number
User defined event number: PTC ALD issues a number of events automatically, e.g. for each page printed or formatted (see api.txt in the OCX install directory).
event_param
A parameter of the event sent to and used by the OCX wrapper application to action whatever it may be configured to do. This number can be generated by a number of means in PTC ALD including getvars, script variables or expressions.
Additional Information
There are two main reason for PTC ALD to issue an event to the enclosing application:
Heartbeats: a system where by the enclosing application can establish whether PTC ALD is still active or it has hung. PTC ALD issues a number of events automatically, e.g. for each page printed or formatted (see api.txt in the OCX install directory). The example defined in Related Links uses a manually generated event; such that when v21812 or v1818 change, an event is issued to the wrapper.
Messages: can be sent via events (although the second parameter can only be of type long, not a string) so you might send an event to the enclosing application to, for example, fill a PTC ALD variable with a certain value or read a predefined string from PTC ALD using the OCX API calls GetText.
* 
When using user defined events like the example, you need to make sure that these do not clash with PTC ALD predefined events, from api.txt:
AdventEvent(long identifier, long lParam)
This event passes two long variables: the first value is the event identifier and the second is some associated value.
Currently PTC ALD uses the following event identifiers:
0xFFFFFFFF
mem : sends the amount of memory PTC ALD is using (note: only sent from DEBUG version).
256
User clicked on a protected field at 'pos' in the current stream.
257
OnOff : Dialog box notification.
258
handle : Current stream notification.
259
page : High-level formatting page 'page' (tformat).
260
page : Printing page 'page' (tprint).
261
page : Low-level formatting page 'page' (trf, tpgoto, tfreeze, tformat, tprint etc.)