السلام عليكم ورحمة الله وبركاته
لدبنا سترينج مثلا
	
كيف نجعله يعطينا النتيجة ؟
							
						لدبنا سترينج مثلا
كود PHP:
	
	
 h = "1+12*45-48/2"; 
 h = "1+12*45-48/2"; 
h = "1+12*45- 48/ 2"
result = loadstring(string.format("return %s",h))()
Dialog.Message("Notice",result); 
--
x="2*3^5-6*4/5";
x = string.gsub("$return "..x.."$", "%$(.-)%$", function (s) 
return loadstring(s)() 
end) 
dialog.message("notice", x);
h = "1+12*45- 48/ 2"
result = loadstring(string.format("return %s",h))()
dialog.message("notice",result); 
function calc(str)
MathCalc = loadstring(string.format("return %s",str))()
return MathCalc
end 
h = "1+12*45- 48/ 2" 
r = "9*3+6-4"
Dialog.Message("Notice", calc(r));
Dialog.Message("Notice", calc (h)); 
Dialog.Message("Notice", MathCalc); 
function calc(str)
mathcalc = loadstring(string.format("return %s",str))()
return mathcalc
end 
h = "1+12*45- 48/ 2" 
r = "9*3+6-4"
dialog.message("notice", calc(r));
dialog.message("notice", calc (h)); 
dialog.message("notice", mathcalc); 
 
							
						
--
x="2*3^5-6*4/5";
x = string.gsub("$return "..x.."$", "%$(.-)%$", function (s) 
return loadstring(s)() 
end) 
Dialog.Message("Notice", x);
x="(((-4*4)/5)+5)-9)";
x = string.gsub("$return "..x.."$", "%$(.-)%$", function (s) 
return loadstring(s)() 
end) 
Dialog.Message("Notice", x); 
x="(((-4*4)/5)+5)-9)"; 


تعليق