Jump to content
Macro Express Forums

Pgm Question


etj01

Recommended Posts

Am trying to understand the why and how to use the { Program - Log Event }

feature in the PGM library. Been through the PGM Functions Library and the help file. Something is not sinking in or it's just Friday.

 

I would like to log some process events that I could turn off and on. What happens to the registry entries when additional events are ready?

 

Hope I've made this clear. Right now I feel the same "wow" when I saw the Direct Editor in ME3. I'd hate to overwrite something in the registry.

 

An option to create a backup of registry changes that gets updated each time thngs are changed, could be used to recover or debug a very bad day of writing and runningcode, from where I am today. Later, I'm sure I'll feel more confortable writing to the reg with PGM calls.

 

Ernie

Link to comment
Share on other sites

Hello etj01!

 

Good question. Thanks for posting it.

 

Event logging allows you to append text to a text event log, text error file, or anything else that you want to call it, without having to turn on the native Macro Express error logging feature, which has limitations.

 

When you installed the PGM Functions Library there were, in addition to others, four Registry keys created:

  • HKCU\Software\Professional Grade Macros\Files\EventLog
  • HKCU\Software\Professional Grade Macros\Folders\Data
  • HKCU\Software\Professional Grade Macros\Parameters\LogEvent?
  • HKCU\Software\Professional Grade Macros\Parameters\Event

These four keys are related to the { Program - Log Event } function and are handled by it, and other functions as well. The third one holds an integer and the others hold a string.

 

The EventLog key is the filename that is being appended to. It defaults to "PGM Event.log", but can be changed to any valid file name that you want. The Data key is the folder that the event log is located. The LogEvent? key is a way to turn logging on and off. 0=off and 1=on. If it is off, then no events will be written to the log, no matter what. If it is turned on, then your designated events will be recorded in the log when they happen. More on this later. The Event key is the event string that gets written to the log. Again, this is a string that you create in whatever macros that use logging. Your choice.

 

You tell the macro what to log, and the { Program - Log Event } function writes it to the file when called. Let's make an assumption or two here. 1) Event logging is turned on and 2) the log is set to its default location and name. Here is an example that you can place at the beginning of any macro to log that the macro has fired:

01  Set Variable %T9% to "Name of Current Macro"
02  If Macro "{ Program - Log Event }" Enabled
03    Write Registry String: "Event"
04    Macro Run: { Program - Log Event }
05  End If

Line 01 sets the T9 string to what you want to record in the log. In this case, it is the name of the macro that is running. Line 02 tests that the { Program - Log Event } function is enabled. If it is, then the event string in variable T9 will be appended to the event log. This is another way to turn off logging. Simply disable the function. Line 03 writes the event string to the Event key in the Registry. Line 04 calls the logging function. Line 05 is self explanatory.

 

This is all there is to using the { Program - Log Event } function. You can place it anywhere, for anything, as many times as you want in any of your macros.

 

We use it for:

  • The start of a function
  • The end of a function
  • To record that a certain section of code was executed
  • Debugging unattended operations
  • Time stamping of events for online downloads
  • Many other uses

Hope this explanation helped! I've attached the sample from above. You must have Macro Express 3.5 and, oh yes, the PGM Functions Library :rolleyes:

LogEventSample.zip

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...