Arduino Mega 2560 Serial Input Cycle Problem

Below find the list of errors produced by that failed try.

sketch_nov08b:11:1: error: expected ',' or ';' before 'void'
 void setup() {
 ^~~~
Somewhere\sketch_nov08b\sketch_nov08b.ino: In function 'void loop()':
sketch_nov08b:19:3: error: 'inbyte' was not declared in this scope
   inbyte = ' ';
   ^~~~~~
Somewhere\sketch_nov08b\sketch_nov08b.ino:19:3: note: suggested alternative: 'byte'
   inbyte = ' ';
   ^~~~~~
   byte
sketch_nov08b:25:10: error: 'i' was not declared in this scope
     for (i = 0; i < SONAR_NUM; i++){
          ^
sketch_nov08b:27:7: error: 'sid' was not declared in this scope
       sid = String(i + 1);
       ^~~
Somewhere\sketch_nov08b\sketch_nov08b.ino:27:7: note: suggested alternative: 'sin'
       sid = String(i + 1);
       ^~~
       sin
sketch_nov08b:28:7: error: 'duration' was not declared in this scope
       duration = sonar[i].ping();
       ^~~~~~~~
Somewhere\sketch_nov08b\sketch_nov08b.ino:28:7: note: suggested alternative: 'union'
       duration = sonar[i].ping();
       ^~~~~~~~
       union
sketch_nov08b:29:7: error: 'distance' was not declared in this scope
       distance = (duration/2)*0.0343;
       ^~~~~~~~
Somewhere\sketch_nov08b\sketch_nov08b.ino:29:7: note: suggested alternative: 'isSpace'
       distance = (duration/2)*0.0343;
       ^~~~~~~~
       isSpace
sketch_nov08b:31:7: error: 'dist' was not declared in this scope
       dist = String(distance);
       ^~~~
Somewhere\sketch_nov08b\sketch_nov08b.ino:31:7: note: suggested alternative: 'div'
       dist = String(distance);
       ^~~~
       div
sketch_nov08b:32:7: error: 'outpackage' was not declared in this scope
       outpackage = "u"+sid+" "+dist+"\n";
       ^~~~~~~~~~
sketch_nov08b:34:34: error: expected primary-expression before '/' token
       Serial1.print(outpackage);*/
                                  ^

Using Strings will not help your performance, nor stability.