Go to: Bottom - FAQ Index - EMME/2 Support Center Home Page


This compilation of frequently asked questions is still under construction. It will get updated on an irregular basis, depending on the time I have available and the ideas that emerge from my support activities. This document has last been changed on May 26, 1996 .


1. Macro Files

1.1. Can macro files be created automatically?

Yes. The best way to create an initial ``skeleton'' version of a macro is to activate the macro learn mode and perform manually the task the macro is supposed to automate. The macro learn mode is activated by the command ~>macroname [parameters] and terminated by the command ~>. While the macro learn mode is active, all interactive answers are saved in the specified macro file. The optional command line parameters are used to substitute any occurrences of %1%, %2%, %3%, ...that appear in the input. This skeleton macro is then usually edited (with a standard text editor) to add comments, flow control and other special features, as needed.

1.2. Where does EMME/2 look for macro files?

The environment variable E2MACROS defines where, how and in which order EMME/2 looks for macro files. Very similar the PATH environment variable in DOS and UNIX, E2MACROS contains a path list which is scanned from left to right whenever a macro is to be opened. The path components are separated by semicolons (;) and each contains either a directory specification (including the final '/'or '\') or a file name template in which a '?' indicates the position of the macro name that was specified when the macro was called. By default, the E2MACROS variable is set to look first for a macro with the given name in the local directory and then in the EMME/2 system macro directory, appending a file extension .mac. The current setting of E2MACROS can be displayed with the EMME/2 menu command files.

2. Macro Commands

2.1. How does a macro know whether it is run under DOS or UNIX?

When writing portable macros that will be run under different operating systems, it is sometimes necessary for the macro to know whether it runs on a DOS or a UNIX system. This might e.g. have an influence on the file name syntax or on the external commands issued from within the macro with the ~! command.

For this purpose, the macro register p can be used to access system parameter 2004, which returns the values 1 for UNIX, 2 for DOS and 3 for VMS. Here an example which deletes the file macrodat.tmp with the proper command for the corresponding operating system:

~p=2001 / system parameter returning type of operation system
~?p=1   / UNIX
~!rm macrodat.tmp
~?p=2   / DOS
~!erase macrodat.tmp
~?p=3   / VMS
~!delete macrodat.tmp

2.2. How can a macro access expression results?

Up to Release 7, macros could only access expression results in the network and matrix calculator modules, by storing them explicitly into scalars and then accessing the scalar via the msX macro substitution. With Release 8 it is now possible to access directly (for both reading and writing) the values of the get()/put() stack via the new special floating point registers g1 to g250. This new mechanism macros to interact directly with any expression evaluation. See the Release 8 Users Manual and the new Release Notes for details.

Back to: Top - FAQ Index - EMME/2 Support Center Home Page

Copyright 1996. Heinz Spiess, EMME/2 Support Center, CH-2558 Aegerten, Switzerland
Last changed on Sun May 26 18:42:37 MET DST 1996