Sign in to follow this  
Followers 0
saio

Calculate from string (variable)

10 posts in this topic

I hope that tha is my final stupid question but i just cant find how to calculate sometnig from a variable

$text5= Clipget ()
$text5 = ;What is here?

in that case the variable contains something like 5+2 or other numbers and other string +/-/X/.....

is thud be simple but I can't get it trouth i made several trys and all of tham failed please help I have another way of doing the operation but it takes too long for the perpes i'm using the script

Share this post


Link to post
Share on other sites



Copy this text.

Go into SciTE and run

$text = ClipGet()
msgbox(0,"",$text)

it literally copies whatever you have saved to the clipboard.


Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites

yes that sends 5+2 and it shud send 7 I need it calculated....

Share this post


Link to post
Share on other sites

I don't understand what you had a hard time comprehending?

Success: Returns a string containing the text on the clipboard. Failure: Sets @error to 1 if clipboard is empty to 2 if contains a non-text entry.

to 3 or 4 if cannot access the clipboard.

So you test it

msgbox(0,"",ClipGet())

The helpfile info seemed pretty cut and dry to me.


Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites

yes that sends 5+2 and it shud send 7 I need it calculated....

You're going to have to separate the numbers at the operator. Look at StringSplit(). Then perform the calculation. You'll have to create an algorithm to check for which operator is in use etc.


Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

ok will try

am... after the split it shud looklike ??? $text1 what here $text2 what here $text 3 What here $Anser

so the calculation shud be than?

$text1=5

$tex2 =+

$text3 = 2

if StringInStr ($text,"+") Then
Local $number1 = Stringleft ("+")
Local $number2 = StringRight ("+")
Else
if StringInStr ($text,"-") Then
  Local $number1 =StringLeft ("-")
  Local $number2 = StringRight ("-")
  ;same for others "X" eth....
EndIf
EndIf
;Get String from the $text???
;How To calculate the result???

no my skript gives error..... any ideas???

Edited by saio

Share this post


Link to post
Share on other sites

If its as simple as all additions, it can look like this:

$text = ClipGet()
$asText = StringSplit($text, "+", 0)
$calcText = 0
For $i = 1 to $asText[0]
    $calcText+=$asText[$i]
Next
msgbox(0,"",$calcText)

Is there a certain pattern to the strings? Such as, is it always addition? Are the values always single digits?


Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites

If you are already creating a "calculation string" (i.e. 4+2, 5-3, etc.) Then you should be able to use the "execute" function to evaluate/calculate it.

Share this post


Link to post
Share on other sites

If you are already creating a "calculation string" (i.e. 4+2, 5-3, etc.) Then you should be able to use the "execute" function to evaluate/calculate it.

Oh nice. That's exactly what you want.


Spoiler

“Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.”

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

than it shud be :

$text = Execute ($anser)

Or i'm wrong again???

That worked 10x

$text = ClipGet ()
$text19 = Execute ($text)
msgbox(48, "The anser is :",$text19)
Edited by saio

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