TRY NOW!
AMPL > >Files and Preprocessing > >How can I edit my model or data file without leaving the AMPL command environment?

Use AMPL’s shell command to invoke the editor you want to use. For example, if your editor is called edit and your file is diet2a.dat, give the command

shell "edit diet2a.dat";

The editor temporarily pops up (or takes over the screen or current window). When you quit the editor, the AMPL prompt reappears, and all models, data and options are as before.

When you have returned from the editor, AMPL cannot tell which files you have changed! Thus to use a changed file, you must reset and read it again. The simplest approach is to reset and re-read everything, as in this example:

ampl: shell "edit diet.mod";
ampl: reset;
ampl: model diet.mod;
ampl: data diet2a.dat;

In most circumstances, however, it’s easier to edit files in their own windows, separate from the windows where you’re running AMPL. Some editors can be configured with syntax highlighting specific to AMPL. You still need to reset and re-read after changing a file, though.

Posted in: Files and Preprocessing