summaryrefslogtreecommitdiffstats
path: root/Bachelor/CCNA4/en_CCNA4_v30/elabs/Engine/actions_output.txt
blob: d19c090428b4f62ef2fc313473509aae6dddbcb8 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
//zmg, 03.01.01

//this file needs a better description!





//Modified by Bargavi 

//to be compatible with Flash MX



// Modified by Dean Wood 05.10.01

//  Changed hard-coded 7s to cursorXOffset

//  Changed hard-coded 15s to cursorYOffset

//  Added call to manual_scrolling_setSlider() in output_writeOut()

//  Added call to manual_scrolling_setSlider() in output_writeOneMore()



// output_setCursor()

// IN : None

// DO : Sets the cursor placement of the cursor object in the HyperTerminal movieclip

// OUT: None

function output_setCursor() {





	with(eval("_root.r" + _root.VISIBLE_ROUTER)) {

		_root.HyperTerminal.cursor._x = (cx + (cursorX * cursorXOffset));

	}

}





// output_initCursor()

// IN : None

// DO : Sets the cursor to invisible and moves it to the correct line

// OUT: None

function output_initCursor() {



	with(eval("_root.r" + _root.VISIBLE_ROUTER)) {

		// set the y position of cursor -> should always be this value

		_root.HyperTerminal.cursor._y = cy + cursorYOffset * cursorY;



		// set the starting visibility of cursor to false

		_root.HyperTerminal.cursor._visible = false;

	}

}





// ***** output_processMore(int) *****

// IN :	An integer representing the key pressed

// DO :	Interpret the key and decide how to continue with the --More--

// OUT: None

function output_processMore(keycode) {



	with(eval("_root.r" + _root.VISIBLE_ROUTER)) {

		// resets the scroll to print more lines

		scrollStartLine = lastDLine - 23;

	}





	if (commandline_matchKey(keycode," ")) {



		// SPACE is pressed

		// write one more page

		output_writeMore();



	} else if (keycode == 13) {



		// ENTER is pressed

		// write one more line

		output_writeOneMore();



	} else {



		// all other keys

		// exit the more state

		output_exitMore();

	}

}











// ***** output_writeMore () *****

// IN : None

// DO :	Write one more page when SPACE is pressed

// OUT: None

function output_writeMore() {





	// pointer to active router object

	var r = eval("_root.r" + _root.VISIBLE_ROUTER);



	// remove the last display line, which is " --More-- "

	r.line.splice(r.lastDLine,1);



	// let the counter know that a line has been removed

	r.lastLine--;





	if ((r.lastDLine+23) < r.lastLine) {



		// if there is one more page after this page

		output_write();



	} else {



		//else change the process back to

		//commandline_processCommandLine and print out

		//the command prompt

		commandline_changeProcess("commandline_processCommandLine");

		commandline_commandLine();

	}

}









// ***** output_exitMore () *****

// IN : None

// DO :	Exits the more state and changes back to the command line

// OUT: None

function output_exitMore() {





	// change process back to commandline_processCommandLine

	commandline_changeProcess("commandline_processCommandLine");



	with(eval("_root.r" + _root.VISIBLE_ROUTER)) {



		// turn the more flag off

		MORE = false;



		// remove the last display line, which is " --More-- "

		line.splice(lastDLine,1);



		// move the display line back to make up for the removal of " --More-- "

		lastDLine--;



		// set the current line to the last display line + 1

		line.length = lastDLine+1;

		lastLine = lastDLine+1;

	}



	// put a line of space between the printed info and the command line

	output_write("\n");



	// print out the command line

	commandline_commandLine();

}











// ***** output_writeOneMore () *****

// IN : None

// DO :	Set up the correct printing operations

// OUT: Write out one line of text and then the " --More-- " cursor

function output_writeOneMore() {





	// pointer to active router object

	var r = eval("_root.r" + _root.VISIBLE_ROUTER);



	// remove the last display line, which is " --More-- "

	r.line.splice(r.lastDLine,1);



	// let the counter know that a line has been removed

	r.lastLine--;



	// turn the 'one at a time printing method' flag on

	r.oneMoreLine = true;



	if ((r.lastDLine+1) < r.lastLine) {



		// if there is another line to print, print it

		output_write();



	} else {



		//else change the process back to

		//commandline_processCommandLine and print out

		//the command prompt

		commandline_changeProcess("commandline_processCommandLine");

		commandline_commandLine();

	}



	manual_scrolling_setSlider();

}











// ***** output_write(strings) *****

// IN :	Any number of strings; provided that every argument can only contain

//      ONE "\n" character that must be at the end of the argument.

// DO :	Store the arguments to <line>

// OUT: None

function output_write() {



	with(eval("_root.r" + _root.VISIBLE_ROUTER)) {





		// if the screen is not already writing

		if (WRITING == false) {



			// go back to the last screen if user has scrolled to another

			indexLine = lastDLine - 23;



			// update the new start line for scrolling

			scrollStartLine = indexLine;

		}







		// store each line of text to the line buffer

		var i=0;

		var o_f = output_feed;

		var len = arguments.length

		for (i=0; i<len; i++) {

			o_f(arguments[i]);

		}





		// if no more than one page of text

		if (MORE == false) {



			// set the last display line to the last line in the buffer

			lastDLine = lastLine;



			// linesToMore is the number of lines to trigger the more function

			var linesToMore = 46;

			if (oneMoreLine == true) {

				linesToMore = 24;

			}



			// if the number of lines is enough to trigger the More function

			if ((lastLine-scrollStartLine) > linesToMore) {



				// set the last display line to the starting line of this page plus linesToMore

				lastDLine = scrollStartLine + linesToMore;



				// add the " --More-- " line to the last display line

				line.splice(lastDLine,0," --More-- \n");



				// let the counter know you've added a line

				lastLine++;



				// turn the More function on

				MORE = true;



				// change process to intepret keys for the more function

				commandline_changeProcess("output_processMore");

			}

		}

		// if the screen is not already writing..

		if (WRITING == false) {



			// turn writing on, then call the writeOut function

			WRITING = true;

			output_writeOut();

		}

	}

}







// ***** output_writeOut() *****

// IN : None

// DO : Write one line at a time from the line buffer to the screen

//      then scroll down. Plays <delay> movie, and the movie calls

//	this function to print the next line

// OUT: Writes the line buffer to the HyperTerminal screen

function output_writeOut() {

//var startTime = getTimer();

//trace("startTime = "+ startTime);





	with(eval("_root.r" + _root.VISIBLE_ROUTER)) {





		// set stop line to different situations

		if (MORE == true) {





			if (oneMoreLine == true) {



				// if we're scrolling one at a time only go forward 2

				stopLine = scrollStartLine + 2;



			} else {



				// else we're scrolling a page at a time

				stopLine = scrollStartLine + 24;

			}





		} else {



			// else leave some space from the bottom when we're done

			stopLine = lastDLine - 22;

		}



		// if this is before the last line to be printed

		if (indexLine < stopLine) {

			//Modified by Bargavi

			// first, clear the screen

			with(eval("_root.HyperTerminal.s" + _root.VISIBLE_ROUTER)) {output.text = String("");} 

			 // clear screen  Bargavi



			// print out 24 lines starting from <indexLine>

			var i=0;

			var target_time =0;

			var i_L = indexLine;

			for (i=i_L; i<(i_L+24); i++) {



				//looking for PAUSE flag

				if (line[i] == "PAUSE\n") {



					// replace PAUSE flag with empty line to maintain line cohesion

					line.splice(i,1,"\n");



					target_time = (getTimer()/1000) + 5; // the time at which to continue



					// waiting for the right time

					for(;target_time>(getTimer()/1000);){

						// trying to update clock during wait

						timer_timeCompute();

					}

				}





				//Bargavi			

                             with(eval("_root.HyperTerminal.s" + _root.active_router ))

				 {

				   output.text =output.text + line[i];

				  } //Bargavi             

			  }





	  		// if this is the last line, then display the cursor

			if (indexLine == (stopLine-1)) {



				if (MORE == true) {

					// if we are printing the More cursor, offset it

					cursorX = 10;

				} else {

					//else the cursor is at the normal position

					cursorX = line[stopLine+22].length;

				}



				_root.HyperTerminal.cursor._x = cx + cursorXOffset * cursorX;



				// show the cursor

				_root.HyperTerminal.cursor._visible = true;



			} else {



				// else we hide the cursor

				_root.HyperTerminal.cursor._visible = false;

			}



			// check for the possible positions of the index line and correct it

			if (indexLine == (stopLine-1)) {

				indexLine++;

			} else if ((indexLine+3) >= stopLine) {

				indexLine = stopLine-1;

			} else {

				indexLine+=3;

			}



			// call the delay movie, and the movie will call back this function

			// to print out the rest of the data

			tellTarget (delay) {

				gotoAndPlay(2);

			}



			

		} else {



			// else everything has been printed and we can stop this loop

			MORE = false;

			oneMoreLine = false;

			WRITING = false;



			manual_scrolling_setSlider();

		}

}

	

//var endTime = getTimer();

//trace("endTime = "+ endTime);

//trace("elapsed time = " + (endTime-startTime)/1000 + "\n");

}













// ***** output_erase(int) *****

// IN :	One integer that is the number of characters to be erased

// DO :	Erase that number of characters

// OUT: The modified line

function output_erase(leng) {



	with(eval("_root.r" + _root.VISIBLE_ROUTER)) {



		// take out the specified # of characters from the last element in line

		line[lastLine] = line[lastLine].substring(0,line[lastLine].length-leng);



		// write out the buffer

		output_write();

	}

}









// ***** output_feed(string) *****

// IN : 1 line of text from output_write()

// DO : Store the text to <line>

// OUT: None

function output_feed(content) {



	with(eval("_root.r" + _root.VISIBLE_ROUTER)) {





		//if the line has over 80 characters, it will split

		//it up into multiple lines.

		

		while((line[lastLine].length+content.length) > 80) {



			// get the number of characters available on the last line

			feedLength = 80 - line[lastLine].length;



			// add as much as you can of the input text to the line

			line[lastLine] += content.substring(0,feedLength) + "\n";



			// subtract the amount given to line from the input

			content = content.substring(feedLength,content.length);



			// tell the line array that it had another line of text added

			lastLine++;

		}



		// add the remaining text to the line buffer

		line[lastLine] += content;



		// if the last character is "\n", then go to next line

		if (content.charAt(content.length-1) == "\n") {

			lastLine++;

		}





  		// if buffer is full, then take out first line in buffer

		while (lastDLine > bufferLength) {



			line.shift();

			lastLine--;

			indexLine--;

			scrollStartLine--;

			lastDLine--;

		}

	}

}









// NEW BY ZMG

// ***** output_write2(array[]) *****

// IN :	Any number of strings; provided that every argument can only contain

//      ONE "\n" character that must be at the end of the argument.

// DO :	Store the arguments to <line>

// OUT: None

function output_write2(hostname,address,arrayOfStrings) {



	with(eval("_root.r" + _root.VISIBLE_ROUTER)) {

                var o_f = output_feed;

		// if the screen is not already writing

		if (WRITING == false) {



			// go back to the last screen if user has scrolled to another

			indexLine = lastDLine - 23;



			// update the new start line for scrolling

			scrollStartLine = indexLine;

		}



		o_f("\n");

		if (hostname == "") {

			o_f("Tracing route to ["+address+"]\n");

		} else {

			output_feed("Tracing route to "+hostname+" ["+address+"]\n");

		}

		o_f("over a maximum of 30 hops:\n");

		o_f("\n");



		// store each line of text to the line buffer

		var i =0;

		var aos = arrayOfStrings.length

		for (i=0; i < aos; i++) {



			o_f(arrayOfStrings[i]);

		}



		o_f("\n");

		o_f("Trace complete.\n");

		o_f("\n");





		// if no more than one page of text

		if (MORE == false) {



			// set the last display line to the last line in the buffer

			lastDLine = lastLine;



			// linesToMore is the number of lines to trigger the more function

			var linesToMore = 46; //this is an initial value

			if (oneMoreLine == true) {

				linesToMore = 24;

			}



			// if the number of lines is enough to trigger the More function

			if ((lastLine-scrollStartLine) > linesToMore) {



				// set the last display line to the starting line of this page plus linesToMore

				lastDLine = scrollStartLine + linesToMore;



				// add the " --More-- " line to the last display line

				line.splice(lastDLine,0," --More-- \n");



				// let the counter know you've added a line

				lastLine++;



				// turn the More function on

				MORE = true;



				// change process to intepret keys for the more function

				commandline_changeProcess("output_processMore");



			}

		}



		// if the screen is not already writing..

		if (WRITING == false) {



			// turn writing on, then call the writeOut function

			WRITING = true;

			output_writeOut();

			//output_setCursor();

		}

	}

}