Using the Display Command Procedure (DPL Code)

When converting a spreadsheet, DPL can create a command procedure file. This is a command file with display functions that will display the DPL version of the model in the Session Log  in roughly the same way it appears in the original spreadsheet.

To create a display command procedure file, choose the Generate Display Command Procedure option in the Convert from Spreadsheet dialog. The command procedure is given the same name as the converted file, except that the last letter of the filename is D and the extension is .DPL. You will need to use Home | Workspace | Add | Imported Program to bring the command file into the workspace. Also, DPL adds the line value index = 0 at the bottom of the converted spreadsheet file. This is necessary for the display procedure to operate, but does not affect your model in any way. The display command procedure for an example spreadsheet appears here.

display("Price per Widget","%-17s");
display(Price,"%26lg");
display("\n");
display("Sales","%-17s");
display(Sales_Level,"%26lg");
display("\n");
display("Gross Profit","%-17s");
display(Gross_Profit,"%26lg");
display('\n");
display("Marketing Costs","%-17s");
display(Marketing,"%26lg");
display("\n");
display("Other Costs","%-17s");
display(Other_Costs,'%26lg');
display("\n');
display("Net Profit","%-17s');
display(Net_Profit,"%26lg");
display("\n");

The display command procedure is very useful for debugging the DPL-to-spreadsheet link. By creating a command file that sets the states of each event in the DPL model and then calls the display procedure (using #include), you can print all the calculations to the Log, rather than using simple commands to display one value at a time.

set Marketing.High;
set Sales_Level.Low;
#include incl_exd.cmd

When this command is executed, the entire spreadsheet is written to the Log:

16:20:26 Executing: (edited) incl_exd.cmd
Price per Widget  15
Sales             5000
Gross Profit      75000
Marketing Costs   10000
Other Costs       5000
Net Profit        60000

Because the display functions used the in the command procedure use spaces to format the output, the report will look better if you use a fixed-pitch font for the Log font.

Versions: DPL Professional, DPL Enterprise, DPL Portfolio

See Also

Display Function

Working in the Command Program