Importing and Exporting Command Files
Imports modeling data in a wide variety of formats so you can exchange modeling data among different Adams products, as well as with other software manufacturer’s products.
Sources of Command Files
There are three possible sources for a
command file:
■Use your system editor to type in Adams commands.
■Convert a
Log file from a previous Adams session into a command file. You should be careful, however, to avoid recursive execution of command files (command file that calls itself). This can happen easily if you try to execute the log file that the system is currently writing. Learn about
Using the Adams View Log File.
■Export a command file to reproduce a model currently in the Adams
Modeling database into Adams command.
Command File Format
A
command file contains the following types of elements:
■Comments, which Adams does not read or execute. Begin comments with exclamation points (!).
■Executable Adams commands, including your responses to prompts from Adams View. The commands are the same ones that you enter in the
Command Window or that Adams executes in response to menu and dialog box choices.
You can also enter pauses in your command file so that Adams View stops and waits for input or a specified time before preceding.
You can use any combination of upper or lowercase characters for commands in a command file, except for text system commands and filenames.
Each command must start a new line. Remember to include the response to any prompts that you expect.
If you find you need more than a single line for a command and its associated parameters, place an ampersand (&) as the last character on the line to be continued. In this way, you can use as many lines as you need for each command.
Command File Example
To help make the command file easier for you to read, many of the lines are blank comment lines.
! Read Adams files eject.gra, eject.req, and eject.res. The data
! will be put into an analysis, named ‘eject’, by default.
!
file analysis read file_name=eject
!
! Remove all but one view (the one that will remain is, the “active” view),
! and display the bottom view in it (this actually recalls from the data
! base the set of view attributes saved under the name “bottom”).
!
view management delete view_name=all
view management restore saved_view_name=bottom
!
! Display frame 150 from the simulation graphics file.
!
graphic_results single_frame_display frame_number=150
!
! Create a Postscript hardcopy file of this frame.
!
hardcopy generate
! Done
!
exit confirmation=yes
Ensuring Upward Compatibility of Command Files
If you want to ensure upward compatibility of your command files with subsequent releases of Adams, use the complete names of commands, not their abbreviations. If you use the menus and dialog boxes in Adams to execute commands, then all the commands are fully expanded in the Adams View log file, which you can then use as source of your command file.
To expand the abbreviations in a command file to complete commands:
1. Add the following commands to the beginning of the command file:
FILE LOG_FILE SET EXPAND_COMMANDS=ON &
COMMAND_WRITE=ON
2. Import the command file into Adams View at the start of a new session.
3. Exit as soon as Adams has read and executed the complete command file.
4. Remove the following commands from the log file:
FILE COMMAND READ FILE_NAME=file_name &
EXIT CONFIRMATION=YES
5. Rename the log file from this session and give it a name to indicate that it is a command file. It is now the original command file with expanded command abbreviations.
Command File Import Error Options
You can specify that Adams do one of the following as it imports
command files:
■Ignore command - Instructs Adams to ignore the line on which it found the error and start processing the next line as a new command. Adams can usually recover and execute subsequent commands in the file. If subsequent commands depend on the results of the invalid command, however, they may fail or give unexpected results.
■Continue the command file execution - Instructs Adams to continue processing the line as if it were typed interactively. This can be dangerous if there is no correction later on in the line, because Adams keeps issuing error messages until the error is corrected. The errors can continue beyond the end of the line, even to the end of the file, if carriage returns are invalid. Use this value only if the command file is a literal recording of your key strokes, complete with back spaces or other corrections of mistakes.
■Cancel the command file execution and abort file - Instructs Adams to immediately close all the command files and returns control to interactive input. This is the most conservative setting because it guarantees subsequent commands will cause no further errors or unexpected results.