run_mrpg_examples.ec 04/07/78 1111.2r 04/03/78 1520.4 39951 &command_line on &if [equal &n 0] &then &goto explain_this_exec_com &if [and [equal &n 2] [equal &1 "DuMmY_ArG"]] &then &goto invoke_mrpg &print run_mrpg_examples.ec: Argument error. &print ^23xNo arguments should be supplied when this exec_com is initially invoked. &print ^23xNeed to supply a number when asked to enter example number. &quit &label explain_this_exec_com &print ^2/A menu of available examples will be displayed. &print Typing in the number of one of the examples causes this exec_com to: &print ^5xA. Extract the selected example from an archive, &print ^5xB. Invoke MRPG for that example, &print ^5xC. In most cases, execute the example. &print Information about any report segments produced will be displayed. &print You may then select another example, if you wish. &label display_menu &print MENU:^/ &print No. Example &print --- ------------------ &print &print 1 filing_cabinet &print 2 two_reports &print 3 hold_and_sort &print 4 begin_hold_assign &print 5 negative_parameter &label select_example &detach &command_line off exec_com &ec_name DuMmY_ArG [response [format_line "^/Enter the number of the example you want to run.^/"]] &command_line on & Control returns here when the second-level invocation of this exec_com ends. &if [query [format_line "^2/Do you want to run another example?^/"]] &then &else &quit &if [query [format_line "Do you remember its number? (Type no to see the menu again.)^/"]] &then &goto select_example &else &goto display_menu & first-level invocation of this exec_com is above this line. &--------------------------------------------------------------------------------------------- & second-level invocation of this exec_com is below this line. &label invoke_mrpg &command_line on &print &if [equal &2 1] &then &goto menu_1 &if [equal &2 2] &then &goto menu_2 &if [equal &2 3] &then &goto menu_3 &if [equal &2 4] &then &goto menu_4 &if [equal &2 5] &then &goto menu_5 &--&if [equal &2 6] &then &goto menu_6 &--&if [equal &2 7] &then &goto menu_7 &--&if [equal &2 8] &then &goto menu_8 &print run_mrpg_examples.ec: Menu number selected (&2) is not in the menu. &quit &label menu_1 archive xf >unbundled>mrpg_examples filing_cabinet.mrpg filing_cabinet.mrpg.input mrpg filing_cabinet -table &print ^/filing_cabinet has been generated and compiled. &print It may be executed by typing either &print ^10xfiling_cabinet &print ^5xor &print ^10xfiling_cabinet -file &print If the -file is omitted, the report will be displayed on your terminal. &print If the -file is typed, the report will be written into a segment named filing_cabinet.report &print If the -file choice is selected, then: &print ^5xTyping print filing_cabinet.report will display the report on your terminal. &print ^5xTyping dprint filing_cabinet.report will send the report to a line printer. &quit &label menu_2 archive xf >unbundled>mrpg_examples two_reports.mrpg two_reports.mrpg.input mrpg two_reports -table two_reports &print ^/two_reports has been generated, compiled, and executed. &print The output is in two_reports.file_one.report and two_reports.file_two.report &quit &label menu_3 archive xf >unbundled>mrpg_examples hold_and_sort.mrpg hold_and_sort.mrpg.input mrpg hold_and_sort -table hold_and_sort &print ^/hold_and_sort has been generated, compiled, and executed. &print Print hold_and_sort.report &quit &label menu_4 archive xf >unbundled>mrpg_examples begin_(1 8)_hold_assign.mrpg begin_9_hold_assign.mrpg.input mrpg begin_(1 8)_hold_assign -table begin_(1 8)_hold_assign &print ^/begin_1_hold_assign has been generated, compiled, and executed. &print begin_8_hold_assign has been generated, compiled, and executed. &print Print begin_1_hold_assign.in.report and begin_1_hold_assign.lv.report &print Print begin_8_hold_assign.in.report and begin_8_hold_assign.lv.report &quit &label menu_5 archive xf >unbundled>mrpg_examples negative_parameter.mrpg negative_parameter.mrpg.input mrpg negative_parameter -table &print ^2/negative_parameter has been generated and compiled. &print Execute the object program without supplying any parameter.^2/ negative_parameter &print ^2/Execute it with a positive argument.^2/ negative_parameter 5 &print ^2/Now execute it using the "negative" argument.^2/ negative_parameter 6 -neg &print ^2/The parameters can be reversed.^2/ negative_parameter -neg 7 &quit  filing_cabinet.mrpg 04/07/78 1111.2r 04/03/78 1518.0 25704 /* A sample program to illustrate many of the MRPG features. This is * filing_cabinet.mrpg in >unbundled>mrpg_examples.archive */ declare 1 parameter, 2 where_to_send_output boolean key ("-file"); declare 1 input stream file "filing_cabinet.mrpg.input", 2 grade char(1) position 1, 2 drawers dec(1) position 4, 2 quantity dec(3) position 7, 2 unit_cost dec(3) position 12; declare quantity_total dec; declare quantity_grand_total dec; declare cost_total dec; declare cost_grand_total dec; declare grade_code_to_name table ("c" -> "Commercial" "f" -> "Fireproof" "u" -> "Utility") varying; declare grade_code_to_supplier table ( "c" -> "Cranston Office Furniture" "f" -> "Firesafe Specialities" "u" -> "Universal Metal Products" ) varying; define 1 report filing_cabinet_inventory break (grade) pagelength 46 on (file "filing_cabinet.report" if (where_to_send_output) or switch "user_output"), 2 pagehead, 3 line 4, 4 "FILING CABINET INVENTORY AS OF " || %mmddyy, 3 line +2, 2 detailhead grade, 3 line +3, 4 "Grade: ", 4 transform (grade, grade_code_to_name) let (quantity_total := 0;), 4 "-- Purchased from: ", 4 transform (grade, grade_code_to_supplier) let (cost_total := 0;), 3 line +2, 4 "N__o.___o_f_D__r_a_w_e_r_s" column 11, 4 "Q__u_a_n_t_i_t_y" column 26, 4 "U__n_i_t_C__o_s_t" column 36, 4 "E__x_t_e_n_d_e_d_C__o_s_t" column 47, 3 line +2, /* Next line provides column numbers for the reader's convenience. */ 4 "----+----1----+----2----+----3----+----4----+----5----+----6", 3 line, 2 detail the_data_line, 3 line, 4 drawers column 17 picture "9", 4 quantity column 31 picture "zz9", 4 unit_cost column 37 picture "$z,zz9", 4 quantity * unit_cost column 51 picture "$zz,zz9" let ( quantity_total := quantity_total + quantity; cost_total := cost_total + quantity * unit_cost; ), 2 detailfoot grade, 3 line +2, 4 " TOTALS: QUANTITY = ", 4 quantity_total column 30 picture "zzz9", 4 "COST" column 44, 4 cost_total column 50 picture "$zzz,zz9" let (quantity_grand_total := quantity_grand_total + quantity_total; cost_grand_total := cost_grand_total + cost_total; ), 2 pagefoot, 3 line 46, 4 " GRAND TOTALS: QUANTITY = ", 4 quantity_grand_total column 29 picture "zzzz9", 4 "COST =" column 40, 4 cost_grand_total column 49 picture "$zzzz,zz9"; begin () hold input; begin ( quantity_grand_total := 0; cost_grand_total := 0;) sort grade, drawers; print the_data_line; end;  filing_cabinet.mrpg.input 04/07/78 1111.3r 04/03/78 1518.0 5580 u 2 10 30 These input data lines are already sorted in the desired u 4 34 50 order. If they were not, another phase that included a u 5 1 60 sort would need to be added to the program. c 2 32 50 These remarks are ignored because the procedures that read c 4 100 84 the input read the 14 declared characters and skip until c 5 40 100 the next newline character is passed over. This skipping f 2 0 100 to a newline occurs because the input file's declaration f 4 8 250 included the "stream" keyword. Each record in this file f 5 3 300 ends with a newline character.  two_reports.mrpg 03/14/78 1233.3r 03/14/78 1232.7 7101 /* Simple program to produce two trivial reports. */ dcl 1 input stream file "two_reports.mrpg.input", 2 the_data char(32); define 1 report report_one pagelength 12 on file "two_reports.file_one.report", 2 pagehead, 3 line 4, 4 "THIS REPORT PRODUCED ON " || %mmddyy, 3 line, 2 detail detail_one, 3 line +2, 4 "Line A, report one. The input is ", 4 the_data, 3 line, 4 "Line B, report one. The input is ", 4 the_data; define 1 report report_two pagelength 12 on file "two_reports.file_two.report", 2 pagehead, 3 line 4, 4 "THIS REPORT PRODUCED ON " || %mmddyy, 3 line, 2 detail detail_two, 3 line +2, 4 "Report two, line A. The input is ", 4 the_data, 3 line, 4 "Report two, line B. The input is ", 4 the_data; begin() print report_one; print report_two; end;  two_reports.mrpg.input 03/14/78 1233.3r 03/14/78 1232.7 594 line 1 of two_reports.mrpg.input line 2 of two_reports.mrpg.input  hold_and_sort.mrpg 03/14/78 1233.4r 03/14/78 1232.7 6624 /* Simple example illustrating hold and sort */ dcl 1 input stream file "hold_and_sort.mrpg.input", 2 kind char(6), 2 in_stock dec(3), 2 price dec(3); dcl accum_value dec; define 1 report bird_value pagelength 14 on file "hold_and_sort.report", 2 pagehead, 3 line 4, 4 "THIS REPORT PRODUCED ON " || %mmddyy, 3 line, 3 line, 4 "Kind In Stock Price Accum Value", 3 line, 4 "------ -------- ----- -----------", 3 line, 2 detail the_data, 3 line, 4 kind char(6) left, 4 in_stock char(10) right, 4 price char(7) right, 4 accum_value char(13) right let (accum_value := accum_value + in_stock * price;); begin () hold input; begin (accum_value := 0;) sort in_stock desc, price asc; print bird_value; end;  hold_and_sort.mrpg.input 03/14/78 1233.4r 03/14/78 1232.7 846 duck 1 4 /* kind, in_stock, price */ finch 4 2 goose 1 3 pigeon 2 4 robin 2 10  begin_1_hold_assign.mrpg 03/14/78 1233.4r 03/14/78 1232.7 36081 /* begin_1_hold_assign.mrpg contains one hold statement. * begin_8_hold_assign.mrpg contains eight holds, one per phase. * These two MRPG programs illustrate the interactions between: * -- hold statements * -- assignment statements inside begin parentheses * -- assignment statements in execute loop * * "in_" denotes input field; "lv_" denotes local variable. * Report names for _1_ version are begin_1_hold_assign.(in lv).report * Report names for _8_ version are begin_8_hold_assign.(in lv).report */ dcl 1 input stream file "begin_9_hold_assign.mrpg.input", 2 in_1 dec(2), 2 in_2 dec(2), 2 in_3 dec(2), 2 in_4 dec(2); dcl lv_1 dec; dcl lv_2 dec; dcl lv_3 dec; dcl lv_4 dec; dcl phase dec; dcl input_record_number dec; define 1 report in_report on file "begin_1_hold_assign.in.report", 2 detail in_data_line, 3 line, 4 "Phase ", 4 phase, 4 "- Record ", 4 input_record_number, 4 " in_1 = ", 4 in_1, 4 " in_2 = ", 4 in_2, 4 " in_3 = ", 4 in_3, 4 " in_4 = ", 4 in_4, 3 line if (input_record_number = 2); /* Blank line between phases. */ define 1 report lv_report on file "begin_1_hold_assign.lv.report", 2 detail lv_data_line, 3 line, 4 "Phase ", 4 phase, 4 "- Record ", 4 input_record_number, 4 " lv_1 = ", 4 lv_1, 4 " lv_2 = ", 4 lv_2, 4 " lv_3 = ", 4 lv_3, 4 " lv_4 = ", 4 lv_4, 3 line if (input_record_number = 2); /* Blank line between phases. */ /* ----- PHASE 1 ----- */ begin (phase := 1; input_record_number := 0; lv_1 := 85; lv_2 := 86; lv_3 := 87; lv_4 := 88;) input_record_number := input_record_number + 1; print in_report; print lv_report; hold in_1, in_2, lv_1, lv_2; /* Same in _1_ and _8_ versions. */ /* ----- PHASE 2 ----- */ begin (phase := phase + 1; input_record_number := 0;) input_record_number := input_record_number + 1; print in_report; print lv_report; /*,,,hold;,,,*/ /* This "hold;" statement is executed in the * _8_ version of this program. */ /* ----- PHASE 3 ----- */ begin (phase := phase + 1; input_record_number := 0; in_1 := in_1 + 1; in_3 := in_3 + 1; lv_1 := lv_1 + 1; lv_3 := lv_3 + 1;) input_record_number := input_record_number + 1; print in_report; print lv_report; /*,,,hold;,,,*/ /* This "hold;" statement is executed in the * _8_ version of this program. */ /* ----- PHASE 4 ----- */ begin (phase := phase + 1; input_record_number := 0;) input_record_number := input_record_number + 1; print in_report; print lv_report; /*,,,hold;,,,*/ /* This "hold;" statement is executed in the * _8_ version of this program. */ /* ----- PHASE 5 ----- */ begin (phase := phase + 1; input_record_number := 0;) input_record_number := input_record_number + 1; in_2 := in_2 + 1; in_4 := in_4 + 1; lv_2 := lv_2 + 1; lv_4 := lv_4 + 1; print in_report; print lv_report; /*,,,hold;,,,*/ /* This "hold;" statement is executed in the * _8_ version of this program. */ /* ----- PHASE 6 ----- */ begin (phase := phase + 1; input_record_number := 0;) input_record_number := input_record_number + 1; print in_report; print lv_report; /*,,,hold;,,,*/ /* This "hold;" statement is executed in the * _8_ version of this program. */ /* ----- PHASE 7 ----- */ begin (phase := phase + 1; input_record_number := 0; in_1 := in_1 + 1; in_3 := in_3 + 1; lv_1 := lv_1 + 1; lv_3 := lv_3 + 1;) input_record_number := input_record_number + 1; in_1 := in_1 + 1; in_3 := in_3 + 1; lv_1 := lv_1 + 1; lv_3 := lv_3 + 1; print in_report; print lv_report; /*,,,hold;,,,*/ /* This "hold;" statement is executed in the * _8_ version of this program. */ /* ----- PHASE 8 ----- */ begin (phase := phase + 1; input_record_number := 0;) input_record_number := input_record_number + 1; print in_report; print lv_report; /*,,,hold;,,,*/ /* This "hold;" statement is executed in the * _8_ version of this program. */ end;  begin_8_hold_assign.mrpg 03/14/78 1233.4r 03/14/78 1232.7 35136 /* begin_1_hold_assign.mrpg contains one hold statement. * begin_8_hold_assign.mrpg contains eight holds, one per phase. * These two MRPG programs illustrate the interactions between: * -- hold statements * -- assignment statements inside begin parentheses * -- assignment statements in execute loop * * "in_" denotes input field; "lv_" denotes local variable. * Report names for _1_ version are begin_1_hold_assign.(in lv).report * Report names for _8_ version are begin_8_hold_assign.(in lv).report */ dcl 1 input stream file "begin_9_hold_assign.mrpg.input", 2 in_1 dec(2), 2 in_2 dec(2), 2 in_3 dec(2), 2 in_4 dec(2); dcl lv_1 dec; dcl lv_2 dec; dcl lv_3 dec; dcl lv_4 dec; dcl phase dec; dcl input_record_number dec; define 1 report in_report on file "begin_8_hold_assign.in.report", 2 detail in_data_line, 3 line, 4 "Phase ", 4 phase, 4 "- Record ", 4 input_record_number, 4 " in_1 = ", 4 in_1, 4 " in_2 = ", 4 in_2, 4 " in_3 = ", 4 in_3, 4 " in_4 = ", 4 in_4, 3 line if (input_record_number = 2); /* Blank line between phases. */ define 1 report lv_report on file "begin_8_hold_assign.lv.report", 2 detail lv_data_line, 3 line, 4 "Phase ", 4 phase, 4 "- Record ", 4 input_record_number, 4 " lv_1 = ", 4 lv_1, 4 " lv_2 = ", 4 lv_2, 4 " lv_3 = ", 4 lv_3, 4 " lv_4 = ", 4 lv_4, 3 line if (input_record_number = 2); /* Blank line between phases. */ /* ----- PHASE 1 ----- */ begin (phase := 1; input_record_number := 0; lv_1 := 85; lv_2 := 86; lv_3 := 87; lv_4 := 88;) input_record_number := input_record_number + 1; print in_report; print lv_report; hold in_1, in_2, lv_1, lv_2; /* Same in _1_ and _8_ versions. */ /* ----- PHASE 2 ----- */ begin (phase := phase + 1; input_record_number := 0;) input_record_number := input_record_number + 1; print in_report; print lv_report; hold; /* This "hold;" statement is commented out in the * _1_ version of this program. */ /* ----- PHASE 3 ----- */ begin (phase := phase + 1; input_record_number := 0; in_1 := in_1 + 1; in_3 := in_3 + 1; lv_1 := lv_1 + 1; lv_3 := lv_3 + 1;) input_record_number := input_record_number + 1; print in_report; print lv_report; hold; /* This "hold;" statement is commented out in the * _1_ version of this program. */ /* ----- PHASE 4 ----- */ begin (phase := phase + 1; input_record_number := 0;) input_record_number := input_record_number + 1; print in_report; print lv_report; hold; /* This "hold;" statement is commented out in the * _1_ version of this program. */ /* ----- PHASE 5 ----- */ begin (phase := phase + 1; input_record_number := 0;) input_record_number := input_record_number + 1; in_2 := in_2 + 1; in_4 := in_4 + 1; lv_2 := lv_2 + 1; lv_4 := lv_4 + 1; print in_report; print lv_report; hold; /* This "hold;" statement is commented out in the * _1_ version of this program. */ /* ----- PHASE 6 ----- */ begin (phase := phase + 1; input_record_number := 0;) input_record_number := input_record_number + 1; print in_report; print lv_report; hold; /* This "hold;" statement is commented out in the * _1_ version of this program. */ /* ----- PHASE 7 ----- */ begin (phase := phase + 1; input_record_number := 0; in_1 := in_1 + 1; in_3 := in_3 + 1; lv_1 := lv_1 + 1; lv_3 := lv_3 + 1;) input_record_number := input_record_number + 1; in_1 := in_1 + 1; in_3 := in_3 + 1; lv_1 := lv_1 + 1; lv_3 := lv_3 + 1; print in_report; print lv_report; hold; /* This "hold;" statement is commented out in the * _1_ version of this program. */ /* ----- PHASE 8 ----- */ begin (phase := phase + 1; input_record_number := 0;) input_record_number := input_record_number + 1; print in_report; print lv_report; hold; /* This "hold;" statement is commented out in the * _1_ version of this program. */ end;  begin_9_hold_assign.mrpg.input 03/14/78 1233.4r 03/14/78 1232.7 162 11121314 21222324  negative_parameter.mrpg 03/14/78 1233.4r 03/14/78 1232.7 8793 /* Illustrate a method that permits the user to supply a * negative value for a parameter. */ dcl 1 parm, 2 the_parameter char(*), 2 neg_key bool key ("-neg"); /* The input data is not used within this program, but is declared * because the MRPG language requires that an input file be declared * in every MRPG program. */ dcl 1 input file "negative_parameter.mrpg.input", 2 dummy_data char(10); dcl actual_value dec; define 1 report the_report pgl 2 on switch "user_output", 2 detail the_detail, 3 line, 4 "Parameter value = " || actual_value; begin() /* Convert this comment into an active statement when the else capability * in MRPG is repaired and delete the two if statements following * this comment. * * if neg_key then actual_value := - the_parameter; * else actual_value := the_parameter; fi; */ if neg_key then actual_value := - the_parameter; fi; if not neg_key then actual_value := the_parameter; fi; print the_report; end;  negative_parameter.mrpg.input 03/14/78 1233.4r 03/14/78 1232.7 99 DUMMY DATA */ ----------------------------------------------------------- Historical Background This edition of the Multics software materials and documentation is provided and donated to Massachusetts Institute of Technology by Group Bull including Bull HN Information Systems Inc. as a contribution to computer science knowledge. This donation is made also to give evidence of the common contributions of Massachusetts Institute of Technology, Bell Laboratories, General Electric, Honeywell Information Systems Inc., Honeywell Bull Inc., Groupe Bull and Bull HN Information Systems Inc. to the development of this operating system. Multics development was initiated by Massachusetts Institute of Technology Project MAC (1963-1970), renamed the MIT Laboratory for Computer Science and Artificial Intelligence in the mid 1970s, under the leadership of Professor Fernando Jose Corbato. Users consider that Multics provided the best software architecture for managing computer hardware properly and for executing programs. Many subsequent operating systems incorporated Multics principles. Multics was distributed in 1975 to 2000 by Group Bull in Europe , and in the U.S. by Bull HN Information Systems Inc., as successor in interest by change in name only to Honeywell Bull Inc. and Honeywell Information Systems Inc. . ----------------------------------------------------------- Permission to use, copy, modify, and distribute these programs and their documentation for any purpose and without fee is hereby granted,provided that the below copyright notice and historical background appear in all copies and that both the copyright notice and historical background and this permission notice appear in supporting documentation, and that the names of MIT, HIS, Bull or Bull HN not be used in advertising or publicity pertaining to distribution of the programs without specific prior written permission. Copyright 1972 by Massachusetts Institute of Technology and Honeywell Information Systems Inc. Copyright 2006 by Bull HN Information Systems Inc. Copyright 2006 by Bull SAS All Rights Reserved */