// ############################## START FUNC ############################################ // This function reads whats in a window and return it as a y*x-matrix. // column_start is the start column, column_end the end column. // row_start is the start row, row_end the end row. // As input, the first column and row in the window is indexed 1 // The values column_end and row_end is included in the matrix // Columns counts only with respect to blanks so /34.2 78.2 9/ is 3 columns // Variables in this function are: // Integers: column_start,column_end,row_start,row_end,bredd,n,m // String variables: a, the_actual_row, refstr, carriage_return // String matrixes: au, row_splitted_by_blanks // Floating number matrix: matrix // If column_start=column_end and row_start=row_end, just one value in one variable is read function read(row_start, row_end, column_start, column_end) { // In order to use variable matrix[0][0] and so on, in the matrix column_start--; row_start--; // a is the main variable for storing and handling of the main window input // It is used along with the string matrix au var a=document.form1.text1.value; document.form1.dummy.value="\n"; // The variable carriage_return is used as a reference for carriage return var carriage_return=document.form1.dummy.value; // The variable refstr defines which charachters that can exist var refstr="abcdefghijklmnopqrstuwvxyzABCDEFGHIJKLMNOPQRSTUWVXYZ_-0123456789,."; // Procedure to ensure that only single blanks separate the values in the string // au=help matrix variable, corresponding to a var au=a.split(" "); // ************ START WHILE LOOP BELOW ********************* while(au.length>1){ a=au.join(" "); au=a.split(" "); } // ************ END OF LOOP ABOVE ******************** // Procedure to rinse the input string from nonsense at start + end // ************ One row loop *************** while(refstr.indexOf(a.charAt(0))==-1) a=a.substring(1,a.length); // ************ End one row loop *********** // ************ One row loop *************** while(refstr.indexOf(a.charAt(a.length-1))==-1) a=a.substring(0,a.length-1); // ************ End one row loop *********** // Procedure to ensure that no middle row begins with a blank au=a.split(carriage_return+" "); a=au.join(carriage_return); // au is now the resulting vector from a, the origin input field, // chopped with respect to carriage returns au=a.split(carriage_return); row_end=Math.min(row_end,au.length); var matrix =new Array(row_end-row_start); var the_actual_row =""; var row_splitted_by_blanks = new Array(0); var bredd =0; var n=0; var m=0; // ************ START LOOP (n) BELOW ********************* for(n=row_start;n