When running an import script (executed from File > Open menu option), the file specified by the user in the Open File dialog is redirected to standard input. This means that any data read from standard input by your import script is actually read from the file specified by the user.
When running an export script (execute from File > Save As or Import/Export > Export Timing Diagram As menu options), standard output is redirected to the file specified by the user in the Save As dialog. Whenever you print something in your export script without specifying a file handle it gets printed to standard output (the export file specified by the user).
Tips on Debugging Waveperl Scripts
Error messages during compilation or execution of a Waveperl script are redirected to a file called waveperl.log. The contents of this file is automatically displayed in a tab in the Report Window. When debugging a new script, it is a good idea to constantly watch this file!
When debugging an export script, the simplest way to view debugging information is to temporarily add extra print statements to your script that will show up in the exported file.
When debugging an import script, the simplest way to view debugging information is to print debug info to waveperl.log. To do this, add the statement:
select STDERR;
to the beginning of your Perl import script. This will redirect the output of print statements to waveperl.log (don't do this for an export script as it will redirect your export output). Of course, you can also open your own file using Perl and print error messages to it using its file handle.
To make a change to your Perl script and execute the new script, modify the script file, save your change, and re-execute the script from WaveFormer. By default, you will have to shut down WaveFormer before it will recognize your changes because WaveFormer caches the scripts it executes. Therefore, before you begin debugging your script you should probably turn off script caching. With script caching off you do NOT have to restart WaveFormer each time you change your script, because WaveFormer will dynamically recompile it. To turn off script caching, select the Import/Export > Edit Object Properties menu option, and add an Application Property named DoNotCacheScripts with a value of True. Be sure to delete or set this property to false after you have finished debugging your script as this option does significantly slow down initial script execution speeds (they get recompiled each time they are run).
Perl and WaveFormer Pro API Documentation
Perl: Before you write your first script, we recommend you visit http://www.perl.com if you haven't programmed in Perl before. There are also many books on Perl available in most bookstores. Next, you will want to read the WaveFormer Pro API documentation. Finally, study the scripts shipped with WaveFormer Pro. The easiest way to begin a new script is to use one of the pre-written scripts as a template.
WaveFormer Pro API Introduction: The file twfapi.txt contains a description of common functions in WaveFormer Pro that can be called from Waveperl scripts.
Sharing your scripts with others: If you write a script and you think it may be useful to other users, we encourage you to email it to us at [email protected] so that it can be shared with other users. It is also important to place a statement in your script that you are placing it in the public domain so that other users can freely use it.
Perl API Commands
The most up-to-date docs are in the two "xs" files located in C:\SynaptiCAD directory. These list all Perl API calls. The btimtwf.xs file lists the core routines for handling timing diagram document information. The twf.xs file has all the rest of the commands (e.g. commands for displaying message boxes, prompting for data, managing windows, detecting currently selected objects, etc. ).