Debian Codegraph @

Ref_Data/nested_heading_prompt.cdump_ref

raw
1
2 $Heading="\n\nQuantity Menu:";
3 $Prompt="Choose Quantity:";
4 OUTER:
5
6 # Code generated by Shell::POSIX::Select v0.09, by tim(AT)TeachMePerl.com
7 # NOTA BENE: Line 1 of this segment must start with {, so user can LABEL it
8 { # **** NEW WRAPPER SCOPE FOR SELECTLOOP #1 ****
9 $Shell::POSIX::Select::DEBUG > 1 and 1 == 1 and
10 warn "LINE NUMBER FOR START OF USER CODE_BLOCK IS: ", __LINE__, "\n";
11 _SEL_LOOP1: { # **** NEW SCOPE FOR SELECTLOOP #1 ****
12
13 # critical for values's contents to be resolved in user's scope
14 local @Shell::POSIX::Select::looplist=(1..4);
15 local $Shell::POSIX::Select::num_values=@Shell::POSIX::Select::looplist;
16
17 $Shell::POSIX::Select::DEBUG > 4 and do {
18 warn "ARRAY VALUES ARE: @Shell::POSIX::Select::looplist\n";
19 warn "NUM VALUES is $Shell::POSIX::Select::num_values\n";
20 warn "user-program debug level is $Shell::POSIX::Select::U_WARN\n";
21 };
22 my $quantity; # LOOP-VAR DECLARATION REQUESTED (perhaps by default) # loop-var declaration appears here
23
24 ;
25 local (
26 $Shell::POSIX::Select::Prompt[1],
27 $Shell::POSIX::Select::menu
28 ) =
29 Shell::POSIX::Select::make_menu(
30 $Shell::POSIX::Select::Heading || "",
31 $Shell::POSIX::Select::Prompt || "" , # Might be overridden in make_menu
32 @Shell::POSIX::Select::looplist
33 );
34
35 # no point in prompting a pipe!
36 local $Shell::POSIX::Select::do_prompt[1] = (-t) ? 1 : 0 ;
37 0 > 2 and warn "do_prompt is $Shell::POSIX::Select::do_prompt[1]\n";
38 if ( defined $Shell::POSIX::Select::menu ) { # No list, no iterations!
39 while (1) { # for repeating prompt for selections
40 # localize, so I don't have to reset for
41 # outer loop on exit from inner
42 local ($Reply);
43 while (1) { # for validating user's input
44 local $Shell::POSIX::Select::bad = 0;
45
46 # local decl suppresses newline on prompt when -l switch turned on
47 {
48 local $\;
49 if ($Shell::POSIX::Select::do_prompt[1]) {
50
51 # When transferring from INNER to OUTER loop,
52 # extra NL before prompt is visually desirable
53
54 if ( $Shell::POSIX::Select::_extra_nl) {
55 print STDERR "\n\n";
56 $Shell::POSIX::Select::_extra_nl=0;
57 }
58 print STDERR
59 "$Shell::POSIX::Select::menu\n$Shell::POSIX::Select::Prompt[1] ";
60 }
61 }
62
63 # $Shell::POSIX::Select::do_prompt=0;
64 # constant prompting depends on style
65 $Shell::POSIX::Select::do_prompt[1]= 0;
66
67 if ( $Shell::POSIX::Select::dump_data ) {
68 $Reply = undef;
69 # dump filtered source for comparison against expected
70 print STDERR "copacetic
71 "; # ensure some output, and flush pending
72 exit 222; # code for graceful, expected, early exit
73 }
74 else {
75 # $^W=0;
76 # warn "Waiting for input";
77 $Eof=0;
78 $Reply = <STDIN>;
79 # warn "Got input";
80 # $^W=1;
81
82 if ( !defined( $Reply ) ) {
83 defined "" and "" ne "" and print STDERR "";
84
85 # need to undef loop var; user may check it!
86 undef $quantity;
87
88 # last Shell::POSIX::Select::_SEL_LOOP1; # Syntax error!
89 # If returning to outer loop, show the prompt for it
90 # warn "User hit ^D";
91 if ( 1 > 1 and -t ) { # reset prompting for outer loop
92 $Shell::POSIX::Select::do_prompt[1-1] = 1; $Shell::POSIX::Select::_extra_nl=1;
93 }
94 0 > 2 and warn "Lasting out of _SEL_LOOP1\n";
95 $Eof=1;
96 last _SEL_LOOP1;
97 }
98 !defined $Reply and die "REPLY accessed, while undefined";
99 chomp $Reply;
100
101 # undo emboldening of user input
102 defined "" and "" ne "" and print STDERR "";
103
104 #print STDERR "$Shell::POSIX::Select::menu\n$Shell::POSIX::Select::Prompt ";
105 if ( $Reply eq "" ) { # interpreted as re-print menu request
106 # Empty input is legit, means redisplay menu
107 $Shell::POSIX::Select::U_WARN > 1 and warn "\tINPUT IS: empty\n";
108 $Shell::POSIX::Select::bad = $Shell::POSIX::Select::do_prompt[1] = 1;
109 }
110 elsif ( $Reply =~ /\D/ ) { # shouldn't be any non-digit!
111 $Shell::POSIX::Select::U_WARN > 0
112 and warn "\tINPUT CONTAINS NON-DIGIT: '$Reply'\n";
113 $Shell::POSIX::Select::bad = 1; # Korn and Bash shell just ignore this case
114 }
115 elsif ( $Reply < 1 or $Reply > $Shell::POSIX::Select::num_values ) {
116 $Shell::POSIX::Select::U_WARN > 0
117 and warn
118 "\t'$Reply' IS NOT IN RANGE: 1 - $Shell::POSIX::Select::num_values\n";
119 $Shell::POSIX::Select::bad = 1; # Korn and Bash shell just ignore this case
120 }
121
122 # warn "BAD is now: $Shell::POSIX::Select::bad";
123 $Shell::POSIX::Select::bad or
124 0 > 2 and warn "About to last out of Reply Validator Loop
125 ";
126 $Shell::POSIX::Select::bad or last; # REPLY VALIDATOR EXITED HERE
127 } # if for validating user input
128 } # infinite while for validating user input
129
130 $quantity = $Shell::POSIX::Select::looplist[$Reply - 1]; # set users' variable
131
132 # USER'S LOOP-BLOCK BELOW
133 # warn "inside Outer loop\n";
134
135 $Heading="\nSize Menu:";
136 $Prompt='Choose Size:';
137
138 # Code generated by Shell::POSIX::Select v0.09, by tim(AT)TeachMePerl.com
139 # NOTA BENE: Line 1 of this segment must start with {, so user can LABEL it
140 { # **** NEW WRAPPER SCOPE FOR SELECTLOOP #2 ****
141 $Shell::POSIX::Select::DEBUG > 1 and 2 == 1 and
142 warn "LINE NUMBER FOR START OF USER CODE_BLOCK IS: ", __LINE__, "\n";
143 _SEL_LOOP2: { # **** NEW SCOPE FOR SELECTLOOP #2 ****
144
145 # critical for values's contents to be resolved in user's scope
146 local @Shell::POSIX::Select::looplist=( qw (L XL) );
147 local $Shell::POSIX::Select::num_values=@Shell::POSIX::Select::looplist;
148
149 $Shell::POSIX::Select::DEBUG > 4 and do {
150 warn "ARRAY VALUES ARE: @Shell::POSIX::Select::looplist\n";
151 warn "NUM VALUES is $Shell::POSIX::Select::num_values\n";
152 warn "user-program debug level is $Shell::POSIX::Select::U_WARN\n";
153 };
154 my $size; # LOOP-VAR DECLARATION REQUESTED (perhaps by default) # loop-var declaration appears here
155
156 ;
157 local (
158 $Shell::POSIX::Select::Prompt[2],
159 $Shell::POSIX::Select::menu
160 ) =
161 Shell::POSIX::Select::make_menu(
162 $Shell::POSIX::Select::Heading || "",
163 $Shell::POSIX::Select::Prompt || "" , # Might be overridden in make_menu
164 @Shell::POSIX::Select::looplist
165 );
166
167 # no point in prompting a pipe!
168 local $Shell::POSIX::Select::do_prompt[2] = (-t) ? 1 : 0 ;
169 0 > 2 and warn "do_prompt is $Shell::POSIX::Select::do_prompt[2]\n";
170 if ( defined $Shell::POSIX::Select::menu ) { # No list, no iterations!
171 while (1) { # for repeating prompt for selections
172 # localize, so I don't have to reset for
173 # outer loop on exit from inner
174 local ($Reply);
175 while (1) { # for validating user's input
176 local $Shell::POSIX::Select::bad = 0;
177
178 # local decl suppresses newline on prompt when -l switch turned on
179 {
180 local $\;
181 if ($Shell::POSIX::Select::do_prompt[2]) {
182
183 # When transferring from INNER to OUTER loop,
184 # extra NL before prompt is visually desirable
185
186 if ( $Shell::POSIX::Select::_extra_nl) {
187 print STDERR "\n\n";
188 $Shell::POSIX::Select::_extra_nl=0;
189 }
190 print STDERR
191 "$Shell::POSIX::Select::menu\n$Shell::POSIX::Select::Prompt[2] ";
192 }
193 }
194
195 # $Shell::POSIX::Select::do_prompt=0;
196 # constant prompting depends on style
197 $Shell::POSIX::Select::do_prompt[2]= 0;
198
199 if ( $Shell::POSIX::Select::dump_data ) {
200 $Reply = undef;
201 # dump filtered source for comparison against expected
202 print STDERR "copacetic
203 "; # ensure some output, and flush pending
204 exit 222; # code for graceful, expected, early exit
205 }
206 else {
207 # $^W=0;
208 # warn "Waiting for input";
209 $Eof=0;
210 $Reply = <STDIN>;
211 # warn "Got input";
212 # $^W=1;
213
214 if ( !defined( $Reply ) ) {
215 defined "" and "" ne "" and print STDERR "";
216
217 # need to undef loop var; user may check it!
218 undef $size;
219
220 # last Shell::POSIX::Select::_SEL_LOOP2; # Syntax error!
221 # If returning to outer loop, show the prompt for it
222 # warn "User hit ^D";
223 if ( 2 > 1 and -t ) { # reset prompting for outer loop
224 $Shell::POSIX::Select::do_prompt[2-1] = 1; $Shell::POSIX::Select::_extra_nl=1;
225 }
226 0 > 2 and warn "Lasting out of _SEL_LOOP2\n";
227 $Eof=1;
228 last _SEL_LOOP2;
229 }
230 !defined $Reply and die "REPLY accessed, while undefined";
231 chomp $Reply;
232
233 # undo emboldening of user input
234 defined "" and "" ne "" and print STDERR "";
235
236 #print STDERR "$Shell::POSIX::Select::menu\n$Shell::POSIX::Select::Prompt ";
237 if ( $Reply eq "" ) { # interpreted as re-print menu request
238 # Empty input is legit, means redisplay menu
239 $Shell::POSIX::Select::U_WARN > 1 and warn "\tINPUT IS: empty\n";
240 $Shell::POSIX::Select::bad = $Shell::POSIX::Select::do_prompt[2] = 1;
241 }
242 elsif ( $Reply =~ /\D/ ) { # shouldn't be any non-digit!
243 $Shell::POSIX::Select::U_WARN > 0
244 and warn "\tINPUT CONTAINS NON-DIGIT: '$Reply'\n";
245 $Shell::POSIX::Select::bad = 1; # Korn and Bash shell just ignore this case
246 }
247 elsif ( $Reply < 1 or $Reply > $Shell::POSIX::Select::num_values ) {
248 $Shell::POSIX::Select::U_WARN > 0
249 and warn
250 "\t'$Reply' IS NOT IN RANGE: 1 - $Shell::POSIX::Select::num_values\n";
251 $Shell::POSIX::Select::bad = 1; # Korn and Bash shell just ignore this case
252 }
253
254 # warn "BAD is now: $Shell::POSIX::Select::bad";
255 $Shell::POSIX::Select::bad or
256 0 > 2 and warn "About to last out of Reply Validator Loop
257 ";
258 $Shell::POSIX::Select::bad or last; # REPLY VALIDATOR EXITED HERE
259 } # if for validating user input
260 } # infinite while for validating user input
261
262 $size = $Shell::POSIX::Select::looplist[$Reply - 1]; # set users' variable
263
264 # USER'S LOOP-BLOCK BELOW
265 # warn "inside Inner loop\n";
266 print "You chose $quantity units of size $size\n";
267 last OUTER;;
268
269 # USER'S LOOP-BLOCK ABOVE
270 # Making sure there's colon (maybe
271 # even two) after codestring above,
272 # in case user omitted after last
273 # statement in block. I might add
274 # another statement below it someday!
275 0 > 2 and warn "At end of prompt-repeating loop
276 ";
277 } # infinite while for repeating collection of selections
278 0 and warn "BEYOND end of prompt-repeating loop
279 ";
280 } # endif (defined $Shell::POSIX::Select::menu)
281 else {
282 $Shell::POSIX::Select::DEBUG > 0 and warn "Shell::POSIX::Select: Select Loop #2 has no list, so no iterations\n";
283
284 if ( $Shell::POSIX::Select::dump_data ) {
285 $Reply = undef;
286 # dump filtered source for comparison against expected
287 print STDERR "copacetic
288 "; # ensure some output, and flush pending
289 exit 222; # code for graceful, expected, early exit
290 }
291 }
292 # return omitted above, to get last expression's value
293 # returned automatically, just like shell's version
294
295
296 } # **** END NEW SCOPE FOR SELECTLOOP #2 ****
297 } # **** END WRAPPER SCOPE FOR SELECTLOOP #2 ****
298 # vi:ts=2 sw=2:
299
300 # warn "outside Inner loop\n";;
301
302 # USER'S LOOP-BLOCK ABOVE
303 # Making sure there's colon (maybe
304 # even two) after codestring above,
305 # in case user omitted after last
306 # statement in block. I might add
307 # another statement below it someday!
308 0 > 2 and warn "At end of prompt-repeating loop
309 ";
310 } # infinite while for repeating collection of selections
311 0 and warn "BEYOND end of prompt-repeating loop
312 ";
313 } # endif (defined $Shell::POSIX::Select::menu)
314 else {
315 $Shell::POSIX::Select::DEBUG > 0 and warn "Shell::POSIX::Select: Select Loop #1 has no list, so no iterations\n";
316
317 if ( $Shell::POSIX::Select::dump_data ) {
318 $Reply = undef;
319 # dump filtered source for comparison against expected
320 print STDERR "copacetic
321 "; # ensure some output, and flush pending
322 exit 222; # code for graceful, expected, early exit
323 }
324 }
325 # return omitted above, to get last expression's value
326 # returned automatically, just like shell's version
327
328
329 } # **** END NEW SCOPE FOR SELECTLOOP #1 ****
330 } # **** END WRAPPER SCOPE FOR SELECTLOOP #1 ****
331 # vi:ts=2 sw=2:
332
333 #warn "outside all loops\n";