What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [?] Pow... err, triggering some function on certain convo events?

Pages: (4): « First « 1 [ 2 ] 3 4 » Last »
[?] Pow... err, triggering some function on certain convo events?
Author: Message:
phalanxii
Full Member
***


Posts: 146
Reputation: 5
32 / Male / Flag
Joined: Aug 2006
Status: Away
RE: [?] Pow... err, triggering some function on certain convo events?
quote:
Originally posted by Mattike
  • Also, is there a way to know if the "is typing message" is shown? I need to call this since if the other contact has emoticons in his/her name, the tab bar gets higher. Therefore, my tab should resize too.
Anyone has an idea to do these? ^o)

I'm not 100% sure on this, but you *may* be able to use Pai's Xniff (ActiveX Packet Sniffer) for this. Personally, I would only use this as a last resort, because it's an extra 500kb for something so minor.

Also, for your functions, you may want to check out Huhu_Manix's Huhu Calculator 1.0. It parses all the examples in your first post perfectly, and includes square roots, trigonometric functions, logarithms and more.
09-17-2006 10:18 AM
Profile PM Find Quote Report
Plik
Veteran Member
*****

Avatar

Posts: 1489
Reputation: 46
35 / Male / –
Joined: Jun 2004
RE: [?] Pow... err, triggering some function on certain convo events?
quote:
Originally posted by phalanxii
Also, for your functions, you may want to check out Huhu_Manix's Huhu Calculator 1.0. It parses all the examples in your first post perfectly, and includes square roots, trigonometric functions, logarithms and more.
But the method it uses (using a http request to use google to parse the equation) is a really horrible way todo it :dodgy:
09-17-2006 12:30 PM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
O.P. RE: [?] Pow... err, triggering some function on certain convo events?
quote:
Originally posted by phalanxii
I'm not 100% sure on this, but you *may* be able to use Pai's Xniff (ActiveX Packet Sniffer) for this. Personally, I would only use this as a last resort, because it's an extra 500kb for something so minor.
The problem is that I can't test it myself, since I am on a wireless connection! :(
quote:
Originally posted by Plik
But the method it uses (using a http request to use google to parse the equation) is a really horrible way todo it :dodgy:
No, really? :P
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
09-17-2006 12:38 PM
Profile E-Mail PM Web Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1622
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
RE: [?] Pow... err, triggering some function on certain convo events?
I think I might have a solution for you.  You can use calc.exe and parse keystrokes to it, then one the equation is finished you just get your script to copy (ctrl+v) and you can the read the last entry in the clipboard.  Read the help file to get the keyboard shortcuts like 'y' for to the power.  It might not be a very nice way of going about this but if anyone else has a better suggestion about doing this have a go at it.
[Image: markee.png]
09-17-2006 12:46 PM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
O.P. RE: [?] Pow... err, triggering some function on certain convo events?
But that would force the script to open the calculator, so the user can close it while it enters the keys. :-/

I guess the best thing I can use is a calculator ActiveX object which accepts a string as input and returns the result. I know it's very lazy, but I really don't know any better. :(
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
09-17-2006 01:04 PM
Profile E-Mail PM Web Find Quote Report
Shondoit
Full Member
***

Avatar
Hmm, Just Me...

Posts: 227
Reputation: 15
36 / Male / Flag
Joined: Jul 2006
RE: [?] Pow... err, triggering some function on certain convo events?
Or perhaps you could use the Postfix method Cookie brought up
I already worked out the parsing of infix to postfix...
Now I'm working on calculating the postfix expression

So hang-on

-edit- Almost finished, done within an hour, I hope (I have to eat :P)

-edit2- It took a little longer than I expected, becuase the function weren't called correctly... But here it is anyway
It's very easy to use... Just call StringName.Calculate()
i.e.:
var Expression = Message.substr(0,4)
Result = Expression.Calculate()

It supports presedence, exponents, parenthese multiplication ( 3(4+1) = 15) and Math object functions and constants, for example, you can calculate a function like this:
Result = "3(1 + sin(PI))^2".Calculate()
or
var x = -4
Result = "-sqrt(abs(x))".Calculate()

code:
String.prototype.ToPostfix = function () {
   var Stack = ""
   var Token = ""
   var Result = ""
   for (var i = 0; i < this.length; i++) {
      Token = this.charAt(i)
      switch (Token) {
         case "(":
            Stack += "("
            break
         case ")":
            while (Stack.length > 0 && Stack.charAt(Stack.length - 1) != "(") {
               Result += Stack.charAt(Stack.length - 1)
               Stack = Stack.substring(0, Stack.length - 1)
            }
            Stack = Stack.substring(0, Stack.length - 1)
            break
         case "^": case "*": case "/": case "+": case "-":
            PopStack()
            break
         default:
            while (/[^()\^*/+-]/.test(this.charAt(i + 1)) && i < this.length) {
               Token += this.charAt(i++ + 1)
            }
            if (/\+|-/.test(this.charAt(i + 1))) {
               if (/e/i.test(this.charAt(i)) && i > 0 && /\d/.test(this.charAt(i - 1))) {
                  Token += this.charAt(i++ + 1)
                  while (/[^()\^*/+-]/.test(this.charAt(i + 1)) && i < this.length) {
                     Token += this.charAt(i++ + 1)
                  }
               }
            }
            if (this.charAt(i + 1) == "(") {
               try {
                  if (typeof(Math[Token])=="function" || eval("typeof("+Token+")=='function'")) {
                     if (eval("typeof("+Token+")!='function'")) {
                        Token = "Math." + Token
                     }
                     Token += this.charAt(i++ + 1)
                     var ParamToken = ""
                     var Parentheses = 0
                     while ((/[^)]/.test(this.charAt(i + 1)) || Parentheses > 0) && i < this.length) {
                        if (this.charAt(i + 1) == "(") Parentheses++; else if (this.charAt(i + 1) == ")") Parentheses--
                        ParamToken += this.charAt(i++ + 1)
                     }
                     var Params = ParamToken.split(/\s*,\s*/)
                     for (Index in Params) {
                        Params[Index] = Params[Index].Calculate()
                     }
                     Token += Params.join(",")
                     Token += this.charAt(i++ + 1)
                  } else {
                     PopStack("*")
                  }
               } catch (e) {
                  return undefined
               }
            }
            Result += "\x01" + Token + "\x01"
            break
      }
   }
   while (Stack.length > 0) {
      Result += Stack.charAt(Stack.length - 1)
      Stack = Stack.substring(0, Stack.length-1)
   }
   return Result.replace(/\s/g, "")
   
   function PopStack (Operator) {
      if (Operator == undefined) Operator = Token
      while (Stack.length > 0 && ((/[\^*/+-]/.test(Operator) && /[\^]/.test(Stack.charAt(Stack.length - 1))) || (/[*/+-]/.test(Operator) && /[*/]/.test(Stack.charAt(Stack.length - 1))) || (/[+-]/.test(Operator) && /[+-]/.test(Stack.charAt(Stack.length - 1))))) {
         Result += Stack.charAt(Stack.length - 1)
         Stack = Stack.substring(0, Stack.length - 1)
      }
      Stack += Operator
   }
}
String.prototype.CalculatePostfix = function () {
   var Stack = new Array()
   var Token = ""
   for (var i = 0; i < this.length; i++) {
      Token = this.charAt(i)
      if (/[^\^*/+-]/.test(Token)) {
         while (/[^\x01]/.test(this.charAt(i + 1)) && i < this.length) {
            Token += this.charAt(i++ + 1)
         }
         Token += this.charAt(i++ + 1)
         if (/\+|-/.test(this.charAt(i + 1))) {
            if (/e/i.test(this.charAt(i)) && i > 0 && /\d/.test(this.charAt(i - 1))) {
               Token += this.charAt(i++ + 1)
               while (/[^()\^*/+-]/.test(this.charAt(i + 1)) && i < this.length) {
                  Token += this.charAt(i++ + 1)
               }
            }
         }
         if (/\x01(.+)\x01/.test(Token)) {
            var Operands = RegExp.$1.split(/\x01\x01/)
            for (Index in Operands) {
               if(eval("typeof("+Operands[Index]+")=='undefined'")) {
                  if (typeof(Math[Operands[Index]]) != "undefined" && typeof(Math[Operands[Index]]) != "function") {
                     Operands[Index] = Math[Operands[Index]]
                  }
               }
            }
            Stack = Stack.concat(Operands)
         } else {
            return undefined
         }
      } else {
         if (Stack.length >= 2) {
            if (Token == "^") {
               Stack[Stack.length - 2] = Math.pow(eval(Stack[Stack.length - 2]), eval(Stack[Stack.length - 1]))
            } else {
               Stack[Stack.length - 2] = eval(eval(Stack[Stack.length - 2]) + Token + eval(Stack[Stack.length - 1]))
            }
            Stack.pop()
         }
      }
   }
   try {
      return eval(Stack[0])
   } catch (e) {
      return undefined
   }
}
String.prototype.Calculate = function () {
   var Postfix = this.ToPostfix()
   if (Postfix != undefined) return Postfix.CalculatePostfix()
}

Cookie, I'm not sure if I missed something... Could you have a look?
I think I took care off all the basic operations..., thx (y) (Why is [noparse] not working for smilies?)

This post was edited on 09-17-2006 at 06:56 PM by Shondoit.
My scripts:                            [Image: shondoit.gif]
+ Timezone
+ Camelo
+ Multisearch
09-17-2006 03:30 PM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: [?] Pow... err, triggering some function on certain convo events?
quote:
Originally posted by Mattike
I'm having lots more problems with the tab itself to change position when the user shows/hides the display pictures, or when the "is typing" message contains emoticons. Read the first post for more, detailed information. ;)
adding something to the formatting bar like that is not going to work. There are way too many complications. Just to name one:
[Image: attachment.php?pid=730968]
where are you going to show the icon/window?

Personally, I would even not attempt to do it because it is a waste of time (unless you do it in the proper way, like Plus! does it... which is extremely hard...)




quote:
Originally posted by Mattike
The thing was to share your calculations with your contacts, not calculating some things for yourself.
Which can perfectly be done with a command... It's just a matter of what you output. see
"CookieRevised's reply to An idea for a script" for an extremely easy Calculator script using the JScript's eval() function.
(a thread which you also participated in ;))


And to make something different, but still based upon the same thing, you can take the idea which is described in this thread, namely: showing all the steps of the calculation.
(though this requires you to forget about infox to postfix calculation (almost) as the calculation need to be calculated in your script using infix style)




quote:
Originally posted by markee
I think I might have a solution for you.  You can use calc.exe and parse keystrokes to it, then one the equation is finished you just get your script to copy (ctrl+v) and you can the read the last entry in the clipboard.
I dunno which is worse, using a HTTP stream and using some form on the web, or sending keystrokes to the (very limited) calc application... :p
quote:
Originally posted by markee
It might not be a very nice way of going about this but if anyone else has a better suggestion about doing this have a go at it.
well... see all my posts in this thread ;):D




quote:
Originally posted by Shondoit
Cookie, I'm not sure if I missed something... Could you have a look?
I'm not going to strip down your routine line per line though (way too much work :p:d).

If your script is based upon the modified version 23/10/02 of Premshree Pillai's code, it should work.

PS: I added yet another link to my infix/postfix post which explains a similar, but other method of converting (recursive method instead of using a stack).

However, I can see you use strings to store the stack? If so, this is not so good. It would be better if you use arrays for this like you do in your CalculatePostfix function.



----------------


Related, and of use for all who are interested in making something which has todo with calulating math expressions:
CookieRevised's reply to Advanced VB coders

.gif File Attachment: image1.gif (22.68 KB)
This file has been downloaded 337 time(s).

This post was edited on 09-18-2006 at 05:07 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
09-17-2006 11:03 PM
Profile PM Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: RE: RE: [?] Pow... err, triggering some function on certain convo events?
quote:
Originally posted by CookieRevised
quote:
Originally posted by Mattike
I'm having lots more problems with the tab itself to change position when the user shows/hides the display pictures, or when the "is typing" message contains emoticons. Read the first post for more, detailed information. ;)
adding something to the formatting bar like that is not going to work. There are way too many complications. Just to name one:
[Image: attachment.php?pid=730968]
where are you going to show the icon/window?

Personally, I would even not attempt to do it because it is a waste of time (unless you do it in the proper way, like Plus! does it... which is extremely hard...)
He wants it with the tabs, not the toolbar.
09-17-2006 11:18 PM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: [?] Pow... err, triggering some function on certain convo events?
quote:
Originally posted by deAd
He wants it with the tabs, not the toolbar.
oh yeah, right... I stand corrected.

Still, what if the writing tab isn't there, what if another tab is added there (some (official) addons add a tab there)...

unless you do it like it should be done, I wouldn't attempt to do it either for same reasons.
.-= A 'frrrrrrrituurrr' for Wacky =-.
09-17-2006 11:42 PM
Profile PM Find Quote Report
phalanxii
Full Member
***


Posts: 146
Reputation: 5
32 / Male / Flag
Joined: Aug 2006
Status: Away
RE: [?] Pow... err, triggering some function on certain convo events?
Changing the subject a little bit, Shondoit's code works really well for me. However, two things:

1. How can I change some of the functions to degrees, not radians?
2. How can I make the functions and properties case-insensitive?

I've sort of figured out 2, but I don't want to edit anything because the script is so complex. :S
09-18-2006 03:54 AM
Profile PM Find Quote Report
Pages: (4): « First « 1 [ 2 ] 3 4 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On