xdp22 Posted March 28, 2011 Share Posted March 28, 2011 Welcome, i need help with calc script from string with func number in example we got string $string = '5+67=' and i need return 72 so Number(5+67) i already try stringsplit with regexp but i do it without success. If it easy for someone and can help me <> thanks Link to comment Share on other sites More sharing options...
UEZ Posted March 28, 2011 Share Posted March 28, 2011 Try this: $string = '5+67' ConsoleWrite(Execute($string) & @CRLF) Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
xdp22 Posted March 28, 2011 Author Share Posted March 28, 2011 u didnt understand me ;/ i need made it from string $string = '5+7=' not just 5+7 but thx Link to comment Share on other sites More sharing options...
Developers Jos Posted March 28, 2011 Developers Share Posted March 28, 2011 u didnt understand me ;/ i need made it from string $string = '5+7=' not just 5+7 but thx so ??? $string = '5+67=' $string = StringReplace($string, "=", '') ; strip the = ConsoleWrite($string & "=" & Execute($string) & @CRLF) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
UEZ Posted March 28, 2011 Share Posted March 28, 2011 u didnt understand me ;/ i need made it from string $string = '5+7='not just 5+7 but thxI did understand you but I wanted to show the Execute command!You should be able to use any string function to remove the = from the string to execute the calculation!Br,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
xdp22 Posted March 28, 2011 Author Share Posted March 28, 2011 its because my bad ebglish i mean this string is only example, its can be '8+99 =' '4+ 67=' '12 + 8 ?' '66 +1 ?' '54+ 8?' understand me?? thanks Link to comment Share on other sites More sharing options...
Jayson Posted March 28, 2011 Share Posted March 28, 2011 You should provide some code so we may help you better. Without it I can only say change the $string = "5+67" to what ever you want. Link to comment Share on other sites More sharing options...
bogQ Posted March 28, 2011 Share Posted March 28, 2011 (edited) #include <Array.au3> $1 = '8+99 =' $2 = '4+ 67=' $3 = '12 + 8 ?' $4 = '66 +1 ?' $5 = '54+ 8?' cb($1) cb($2) cb($3) cb($4) cb($5) Func cb($data) Local $Arr = StringSplit(StringReplace($data," ",""),"") Local $fi,$se,$del,$count=1 If StringIsDigit($arr[1]) Then Do $del=$del&$Arr[$count] $count += 1 Until Not StringIsDigit($arr[$count]) $fi=$del Else Exit EndIf $del = "" Do $del=$del&$Arr[$count] $count += 1 Until Not StringIsDigit($arr[$count]) $se=$del ConsoleWrite(Execute($fi&$del)&@CRLF) EndFunc dumb way Probably there is faster solution with StringRegExp Edited March 28, 2011 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
UEZ Posted March 28, 2011 Share Posted March 28, 2011 Is this one what you are looking for? #include <Array.au3> Dim $aStrings[5] = ['8+99 =', '4+ 67=', '12 + 8 ?', '66 +1 ?', '54+ 8?'] For $i = 0 To UBound($aStrings) - 1 $aChk = StringRegExp(StringStripWS($aStrings[$i], 8), "[\d+]+[\+|\-|\*|\/][\d]+", 3) ConsoleWrite(Execute(_ArrayToString($aChk, "")) & @CRLF) Next Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
xdp22 Posted March 29, 2011 Author Share Posted March 29, 2011 Man it's GREAT ! THANKS!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now