فهرست منبع

Merge branch 'fixFloatVector' of LInE/ivprog into master

Lucas de Souza 5 سال پیش
والد
کامیت
7685956794
2فایلهای تغییر یافته به همراه75 افزوده شده و 25 حذف شده
  1. 73 25
      js/visualUI/code_generator.js
  2. 2 0
      js/visualUI/commands/generic_expression.js

+ 73 - 25
js/visualUI/code_generator.js

@@ -69,7 +69,7 @@ function functionsCode (function_obj) {
 	for (var j = 0; j < function_obj.parameters_list.length; j++) {
 		ret += parametersCode(function_obj.parameters_list[j]);
 		if ((j + 1) < function_obj.parameters_list.length) {
-			ret += ',';
+			ret += ', ';
 		}
 	}
 
@@ -812,17 +812,31 @@ function variablesCode (variable_obj) {
 
 		switch (temp.type) {
 			case Types.INTEGER:
-				ret += '= {' + temp.value + '}';
+				ret += '= {';
+				for (var j = 0; j < temp.value.length; j++) {
+					ret += temp.value[j];
+					if ((j + 1) < temp.value.length) {
+						ret += ', ';
+					}
+				}
+				ret += '}';
 				break;
 			case Types.REAL:
-				ret += '= {' + temp.value.toFixed(2) + '}';
+				ret += '= {';
+				for (var j = 0; j < temp.value.length; j++) {
+					ret += temp.value[j].toFixed(2);
+					if ((j + 1) < temp.value.length) {
+						ret += ', ';
+					}
+				}
+				ret += '}';
 				break;
 			case Types.TEXT:
 				ret += '= {';
 				for (var j = 0; j < temp.value.length; j++) {
 					ret += '"'+temp.value[j]+'"';
 					if ((j + 1) < temp.value.length) {
-						ret += ',';
+						ret += ', ';
 					}
 				}
 				ret += '}';
@@ -836,7 +850,7 @@ function variablesCode (variable_obj) {
 						ret += LocalizedStrings.getUI("false");
 					}
 					if ((j + 1) < temp.value.length) {
-						ret += ',';
+						ret += ', ';
 					}
 				}
 				ret += '}';
@@ -851,10 +865,19 @@ function variablesCode (variable_obj) {
 				ret += '= {';
 
 				for (var j = 0; j < temp.rows; j++) {
-					ret += '{' + temp.value[j] + '}';
+					ret += '{';
+
+					for (var k = 0; k < temp.columns; k++) {
+						ret += temp.value[j][k];
 
+						if ((k + 1) < temp.columns) {
+							ret += ', ';
+						}
+					}
+
+					ret += '}';
 					if ((j + 1) < temp.rows) {
-						ret += ',';
+						ret += ', ';
 					}
 				}
 
@@ -864,10 +887,19 @@ function variablesCode (variable_obj) {
 				ret += '= {';
 
 				for (var j = 0; j < temp.rows; j++) {
-					ret += '{' + temp.value[j].toFixed(2) + '}';
+					ret += '{';
+
+					for (var k = 0; k < temp.columns; k++) {
+						ret += temp.value[j][k].toFixed(2);
+
+						if ((k + 1) < temp.columns) {
+							ret += ', ';
+						}
+					}
 
+					ret += '}';
 					if ((j + 1) < temp.rows) {
-						ret += ',';
+						ret += ', ';
 					}
 				}
 
@@ -883,13 +915,13 @@ function variablesCode (variable_obj) {
 						ret += '"' + temp.value[j][k] + '"';
 
 						if ((k + 1) < temp.columns) {
-							ret += ',';
+							ret += ', ';
 						}
 					}
 
 					ret += '}';
 					if ((j + 1) < temp.rows) {
-						ret += ',';
+						ret += ', ';
 					}
 				}
 				ret += '}';
@@ -908,13 +940,13 @@ function variablesCode (variable_obj) {
 						}
 
 						if ((k + 1) < temp.columns) {
-							ret += ',';
+							ret += ', ';
 						}
 					}
 
 					ret += '}';
 					if ((j + 1) < temp.rows) {
-						ret += ',';
+						ret += ', ';
 					}
 				}
 				ret += '}';
@@ -981,14 +1013,21 @@ function globalsCode () {
 
 				switch (temp.type) {
 					case Types.INTEGER:
-						ret += '= {' + temp.value + '}';
+						ret += '= {';
+						for (var j = 0; j < temp.value.length; j++) {
+							ret += temp.value[j];
+							if ((j + 1) < temp.value.length) {
+								ret += ', ';
+							}
+						}
+						ret += '}';
 						break;
 					case Types.REAL:
 						ret += '= {';
 						for (var j = 0; j < temp.value.length; j++) {
 							ret += temp.value[j].toFixed(2);
 							if ((j + 1) < temp.value.length) {
-								ret += ',';
+								ret += ', ';
 							}
 						}
 						ret += '}';
@@ -998,7 +1037,7 @@ function globalsCode () {
 						for (var j = 0; j < temp.value.length; j++) {
 							ret += '"'+temp.value[j]+'"';
 							if ((j + 1) < temp.value.length) {
-								ret += ',';
+								ret += ', ';
 							}
 						}
 						ret += '}';
@@ -1012,7 +1051,7 @@ function globalsCode () {
 								ret += LocalizedStrings.getUI("false");
 							}
 							if ((j + 1) < temp.value.length) {
-								ret += ',';
+								ret += ', ';
 							}
 						}
 						ret += '}';
@@ -1027,10 +1066,19 @@ function globalsCode () {
 						ret += '= {';
 
 						for (var j = 0; j < temp.rows; j++) {
-							ret += '{' + temp.value[j] + '}';
+							ret += '{';
+
+							for (var k = 0; k < temp.columns; k++) {
+								ret += temp.value[j][k];
+
+								if ((k + 1) < temp.columns) {
+									ret += ', ';
+								}
+							}
 
+							ret += '}';
 							if ((j + 1) < temp.rows) {
-								ret += ',';
+								ret += ', ';
 							}
 						}
 
@@ -1046,13 +1094,13 @@ function globalsCode () {
 								ret += temp.value[j][k].toFixed(2);
 
 								if ((k + 1) < temp.columns) {
-									ret += ',';
+									ret += ', ';
 								}
 							}
 
 							ret += '}';
 							if ((j + 1) < temp.rows) {
-								ret += ',';
+								ret += ', ';
 							}
 						}
 
@@ -1068,13 +1116,13 @@ function globalsCode () {
 								ret += '"' + temp.value[j][k] + '"';
 
 								if ((k + 1) < temp.columns) {
-									ret += ',';
+									ret += ', ';
 								}
 							}
 
 							ret += '}';
 							if ((j + 1) < temp.rows) {
-								ret += ',';
+								ret += ', ';
 							}
 						}
 						ret += '}';
@@ -1093,13 +1141,13 @@ function globalsCode () {
 								}
 
 								if ((k + 1) < temp.columns) {
-									ret += ',';
+									ret += ', ';
 								}
 							}
 
 							ret += '}';
 							if ((j + 1) < temp.rows) {
-								ret += ',';
+								ret += ', ';
 							}
 						}
 						ret += '}';

+ 2 - 0
js/visualUI/commands/generic_expression.js

@@ -108,6 +108,7 @@ export function renderExpression (command, function_obj, div_to_render, expressi
 	        put: false // Do not allow items to be put into this list
 	    },
 	    draggable: '.single_element_expression',
+	    handle: '.element_expression_handle',
 	    sort: false,
 	    filter: '.not_allowed',
 	    
@@ -247,6 +248,7 @@ function renderElements (command, function_obj, div_to_render, expression_array,
 	for (i = 0; i < expression_array.length; i++) {
 		if (expression_array[i].type == "var_value") {
 			var div_temp = $('<div class="single_element_expression" data-index="'+i+'"></div>');
+			div_temp.append('<div class="element_expression_handle" style="display: inline; width: 2px solid red; width: 20px; height: 15px;"></div>');
 			if (i == 0) {
 				if (expression_array.length > 0  && !expression_array[0].type_op) {