Skip to content

Commit

Permalink
support string values also of type 10
Browse files Browse the repository at this point in the history
  • Loading branch information
sunilshetye committed Jun 18, 2024
1 parent b95be55 commit 32de2e6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
14 changes: 9 additions & 5 deletions SendLog.py
Original file line number Diff line number Diff line change
Expand Up @@ -1219,11 +1219,11 @@ def list_variables(filename):
'''

command = "[__V1,__V2,__V3]=listvarinfile('%s');" % filename
command += "__V5=grep(string(__V2),'/^[124568]$/','r');"
command += "__V5=grep(string(__V2),'/^([124568]|1[0])$/','r');"
command += "__V1=__V1(__V5);"
command += "__V2=__V2(__V5);"
command += "__V3=list(__V3(__V5));"
command += "__V5=grep(__V1,'/^[^%]+$/','r');"
command += "__V5=setdiff(grep(__V1,'/^[^%]+$/','r'),grep(__V1,'/^PWD$/','r'));"
command += "if ~isempty(__V5) then;"
command += "__V1=__V1(__V5);"
command += "__V2=__V2(__V5);"
Expand All @@ -1239,16 +1239,20 @@ def list_variables(filename):
command += "__V9=__V9+'{\"\"name\"\":\"\"'+__V18+'\"\",'+"
command += "'\"\"type\"\":\"\"'+string(__V28)+'\"\",'+"
command += "'\"\"size\"\":\"\"'+sci2exp(__V38)+'\"\",'+"
command += "'\"\"value\"\":\"\"';"
command += "'\"\"value\"\":';"
command += "if size(__V38,2)>1 then;"
command += "__V10=__V38(1)*__V38(2);"
command += "else;"
command += "__V10=__V38;"
command += "end;"
command += "if __V10<=100 then;"
command += "if __V28<>10 then;"
command += "__V9=__V9+'\"\"'+sci2exp(evstr(__V18))+'\"\"';"
command += "else;"
command += "__V9=__V9+sci2exp(evstr(__V18));"
command += "end;"
command += "__V9=__V9+'\"\"}';"
command += "end;"
command += "__V9=__V9+'}';"
command += "if __V8<size(__V5,2) then;"
command += "__V9=__V9+',';"
command += "end;"
Expand All @@ -1265,7 +1269,7 @@ def load_variables(filename):
'''

command = "[__V1,__V2]=listvarinfile('%s');" % filename
command += "__V5=grep(string(__V2),'/^([124568]|1[7])$/','r');"
command += "__V5=grep(string(__V2),'/^([124568]|1[07])$/','r');"
command += "__V1=__V1(__V5);"
command += "__V2=__V2(__V5);"
command += "__V5=grep(__V1,'/^[^%]+$/','r');"
Expand Down
4 changes: 2 additions & 2 deletions webapp/data_structures/CLR.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ function CLR() {
return options
}
CLR.prototype.set = function CLR() {
this.num = arguments[0]["num"]
this.den = arguments[0]["den"]
this.num = inversepolynomial(arguments[0]["num"])
this.den = inversepolynomial(arguments[0]["den"])
this.value = cont_frm(this.num,this.den);
var model = scicos_model();
model.sim = list(new ScilabString(["csslti4"]), new ScilabDouble([4]));
Expand Down
4 changes: 2 additions & 2 deletions webapp/data_structures/DLR.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ function DLR() {
return options
}
DLR.prototype.set=function DLR(){
this.num=arguments[0]["num"]
this.den=arguments[0]["den"]
this.num = inversepolynomial(arguments[0]["num"])
this.den = inversepolynomial(arguments[0]["den"])
var a=[];
var b=[];
var j=0;
Expand Down
4 changes: 2 additions & 2 deletions webapp/data_structures/STEP_FUNCTION.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ function STEP_FUNCTION() {
}

var initial1 = inverse(temp_initial);
var final1 = inverse(temp_final);
this.step = temp_step;
var final1 = inverse(temp_final);
this.step = inverse(temp_step);
this.initial = temp_initial;
this.final = temp_final;
var temp_initial_1 = colon_operator(initial1);
Expand Down
20 changes: 20 additions & 0 deletions webapp/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -1449,6 +1449,26 @@ function inverse(arg) {
}
}

function inversepolynomial(arg) {
var regex_special = /^[sz]$/;
var regex_char = /^[a-zA-Z_][a-zA-Z_0-9]*$/;
arg = arg.trim();
if (!regex_special.test(arg) && regex_char.test(arg)) {
// Check context variable exist or not
var return_str = get_value_for_variable_from_context(arg);
if (return_str != null) {
arg = return_str;
} else {
// get variable value from workspace variable map.
var return_map = get_value_for_variable_from_workspace(arg);
if (return_map != null) {
arg = return_map.value;
}
}
}
return arg;
}

// replaces ',' by " " and ];[ by ;
// e.g.
// [[-1,-1];[-2,-2]] => '-1 -1;-1 -1'
Expand Down

0 comments on commit 32de2e6

Please sign in to comment.