Editing the Dependencies of an Event

[This is preliminary documentation and subject to change.]

Any event that depends implicitly on one or more other events to function correctly has dependencies. An example is an event that downloads an enhancement page that contains an image. If the image file is not also downloaded, the page will appear broken when it is displayed. The image file is a dependency of the page-download event.

The stream compiler objects can automatically calculate the dependencies of an event. In addition, they provide properties that your application can use to set or edit an event's dependencies.

For example, your application might edit a dependency list when there are two consecutive events that depend on the same image file. You could edit the dependencies of the second event to remove the reference to the shared image file since it will already have been downloaded as a dependency of the first event.

There are two ways in which your application can create a dependency list for an event:

  1. Call EnhEvent.Flatten on an event which does not have a dependency list. This causes the stream compiler objects to automatically calculate the event's dependencies.
  2. Explicitly set dependencies for an event using the EnhEvent.Depend array.

Once a dependency list has been generated, it is stored in the text of the event. For example, in the following, the file First.htm depends on three image files: Red.gif, Green.gif, and Yellow.gif.

before 00:00:20.00 "First.htm" only depends("red.gif" "green.gif" "yellow.gif");
 

The dependency list is stored in the event text to alert the stream compiler objects that dependencies have already been determined for this event and do not need to be re-calculated.

You can edit an event's dependency list using EnhEvent.Depend. Depend is an array of strings containing the path and filename of each dependency file. For example, the preceding event sets Depend(0) to "Red.gif", Depend(1) to "Green.gif", and Depend(2) to "Yellow.gif". A related property, EnhEvent.DependCount, returns the number of dependencies currently set for the event.

To delete a dependency from an event, set its path and filename to an empty string. When you do this, the stream compiler objects delete the empty dependency from the list and re-index the remaining array elements.

The following deletes all of an event's dependencies.

'Delete all the dependencies of an event.
While e.DependCount > 0
    e.Depend(0) = ""
Wend
 

Note that in the preceding example the index is always 0. Because the dependency array is re-indexed after each element is removed, incrementing the index would cause the array to go out of bounds.

When adding dependencies to an event, you can only add one dependency to the list at a time and only at the end of the array.

'Adding a new dependency to an event
e.Depend(e.DependCount) = "Another.gif"
 

If you set a value in the middle of the dependency array, it overwrites the previous value.

'Overwriting a previous dependency value.
e.Depend(1) = "Another.jpg"