分类: 系统运维
2012-05-18 11:13:55
如果你被这章习题难住了的话,记得我们之前教过的:找到不同点、注意细节。
EX4
0001.00 D Cars S 10S 0EX4F
0001.00 D Cars S 10S 0
0002.00 D Space_in_a_car S 10S 1
0003.00 D Drivers S 10S 0
0004.00 D passengers S 10S 0
0005.00 D Cars_not_driven...
0006.00 D S 10S 0
0007.00 D Carpool_capacity...
0008.00 D S 10S 1
0009.00 D Average_passengers_per_car...
0010.00 D S 10S 0
0011.00 D Cars_driven S 10S 0
0012.00 D String S 51A
0013.00 D Wait S 1A
0014.00 /free
0015.00 Cars = 100;
0016.00 Space_in_a_car = 4.0;
0017.00 Drivers = 30;
0018.00 Passengers = 90;
0019.00 Cars_not_driven = Cars - Drivers;
0020.00 Cars_driven = Drivers;
0021.00 Carpool_capacity = Cars_driven * Space_in_a_car;
0022.00 Average_passengers_per_car = Passengers / Cars_driven;
0023.00
0024.00 String = 'There are ' + %char(Cars) + ' cars available.';
0025.00 Dsply String;
0026.00 String = 'There are only ' + %char(Drivers) + ' drivers available.';
0027.00 Dsply String;
0028.00 String = 'There will be ' + %char(Cars_not_driven) +
0029.00 ' empty cars today.';
0030.00 Dsply String;
0031.00 String = 'We can transport ' + %char(Carpool_capacity) +
0032.00 ' people today.';
0033.00 Dsply String;
0034.00 String = 'We have ' + %char(Passengers) + ' to carpool today.';
0035.00 Dsply String;
0036.00 String = 'We need to put about ' +
0037.00 %char(Average_passengers_per_car) +
0038.00 ' in each car.';
0039.00 Dsply String '' Wait;
0040.00
0041.00 *inlr = *on;
0042.00 return;
0043.00
0044.00 /end-free当我刚开始写这个程序时我犯了个错误,RPGLE 告诉我这样的错误信息:
20 D Carpool_capacity...
21 D S 10S 0
……
33 C Eval Car_pool_capacity = Cars_driven *
34 C Space_in_a_car
*RNF7030 30 1 The name or indicator is not defined.
*RNF7030 30 33 003300 The name or indicator CAR_POO... is not defined.
用你自己的话解释一下这个错误信息,解释时记得使用行号,而且要说明原因。
RPGLE中变量名是不区分大小写的。
更多的加分习题:
1. 如何查看编译错误。试一试命令WRKSPLF,然后按SHIFT+F6,看看能找到什么信息
2. 在每一个变量赋值的上一行加上一行注解
3. 记住 = 的名字是等于(equal),它的作用是为东西取名
4. 记住 _ 是下划线字符(underscore)
5. 函数%char()的作用是什么,为什么使用它