1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 bce_query:
32 procedure (Answer) ;
33
34 declare arg_count_ entry returns (fixed bin);
35 declare cu_$arg_list_ptr entry returns (pointer);
36 declare ioa_$general_rs entry (ptr, fixed bin, fixed bin, char (*), fixed bin (21), bit (1) aligned,
37 bit (1) aligned);
38 declare bce_data$error_put_chars ext entry (ptr, ptr, fixed bin, fixed bin (35)) variable;
39 declare bce_data$get_line ext entry (ptr, ptr, fixed bin, fixed bin, fixed bin (35)) variable;
40
41 declare Answer char (*);
42 declare Yes_No bit (1);
43
44 declare requery char (25) static options (constant) init ("Please answer yes or no: ");
45
46 declare buffer char (256);
47 declare used fixed bin (21);
48 declare yes_no bit (1);
49 declare just_get bit (1) aligned;
50 declare n_read fixed bin;
51 declare (substr, length, addr) builtin;
52
53 declare arg_list_ptr pointer;
54 %page;
55
56 yes_no = "0"b;
57 just_get = (arg_count_ () < 2);
58 go to COMMON;
59
60
61 get_line:
62 entry (Answer);
63
64 yes_no = "0"b;
65 just_get = "1"b;
66 go to COMMON;
67
68 yes_no:
69 entry (Yes_No);
70
71 yes_no = "1"b;
72 just_get = (arg_count_ () < 2);
73
74 COMMON:
75 arg_list_ptr = cu_$arg_list_ptr ();
76 if ^just_get
77 then do;
78 buffer = "";
79 call ioa_$general_rs (arg_list_ptr, 2, 3, buffer, used, "0"b, "0"b);
80 call bce_data$error_put_chars (addr (bce_data$error_put_chars), addr (buffer), (used), (0));
81 end;
82
83 buffer = "";
84
85 if yes_no
86 then do while (buffer = "");
87 call bce_data$get_line (addr (bce_data$get_line), addr (buffer), length (buffer), n_read, (0));
88 buffer = substr (buffer, 1, n_read - 1 );
89 if buffer = "yes" | buffer = "y"
90 then go to RETURN_YES;
91 else if buffer = "no" | buffer = "n"
92 then go to RETURN_NO;
93 call bce_data$error_put_chars (addr (bce_data$error_put_chars), addr (requery), length (requery), (0));
94 buffer = "";
95 end;
96
97
98
99 Answer = "";
100 buffer = "";
101 call bce_data$get_line (addr (bce_data$get_line), addr (buffer), length (buffer), n_read, (0));
102 Answer = substr (buffer, 1, n_read - 1 );
103 return;
104
105 RETURN_YES:
106 Yes_No = "1"b;
107 return;
108 RETURN_NO:
109 Yes_No = "0"b;
110 return;
111 end bce_query;