Jump to content

Recommended Posts

Posted

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

Posted

Copy this text.

Go into SciTE and run

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

it literally copies whatever you have saved to the clipboard.

  Reveal hidden contents

 

Posted

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

  Quote

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.

  Reveal hidden contents

 

Posted

  On 5/14/2012 at 1:18 PM, 'saio said:

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.

  Reveal hidden contents

 

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
Posted

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?

  Reveal hidden contents

 

Posted

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.

Posted

  On 5/14/2012 at 2:26 PM, 'spudw2k said:

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.

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...