Sign in to follow this  
Followers 0
xdp22

count from string

10 posts in this topic

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

Share this post


Link to post
Share on other sites



u didnt understand me ;/ i need made it from string

$string = '5+7='

not just 5+7

but thx

Share this post


Link to post
Share on other sites

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)

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

u didnt understand me ;/ i need made it from string

$string = '5+7='

not just 5+7

but thx

I 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!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
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.

 

Share this post


Link to post
Share on other sites

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!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

Man it's GREAT ! THANKS!!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0