What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [?] Calculator in trouble!

[?] Calculator in trouble!
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
O.P. [?] Calculator in trouble!
Okay, you still remember my Calculator? And all the trouble we had with it?

Well, it returned. :P Since I'm working intensively on it to get it ready for the contest, I bumped on probably the craziest problem I ever had with it.
When I try to calculate this:
quote:
-Sin(2)
it fails. The problem lies in this line of code:
code:
if (typeof(Math[Token.toLowerCase()])=="function" || eval("typeof("+(Token.toLowerCase())+")=='function'")) {
since Token has a value of "-Sin" and thus the first statement fails and the second returns an error. ("typeof(-Sin) == 'function'" doesn't work because of the negation sign) I did note that Shondoit, the original creator of the calculating functions (<3), already tried to fix this by using:
code:
var firstChar = this.charAt(i-Token.length);
...
if(firstChar == "-") Token = "-" + Token;
but that's placed in the if-statement and it doesn't seem to work outside it either. Soo... if some very clever person reads this and takes a look at the functions, I'd appreciate it enormously if you can give some hints to fix it.

The attachment contains a snip from my code which executes the calculations. To use it, use something like this:
code:
var str = "-Sin(2)";
Debug.Trace(str.Calculate());

Thanks in advance! :)

.txt File Attachment: calc_prob.txt (6.86 KB)
This file has been downloaded 124 time(s).

This post was edited on 12-06-2006 at 04:44 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
12-05-2006 06:34 PM
Profile E-Mail PM Web Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: [?] Calculator in trouble!
code:
Token += this.charAt(i++ + 1);

Sorry for posting without giving a good answer, but that really hurts my eyes!! Please make it:
code:
Token += this.charAt(++i);


And this doesn't look Ok to me either:
code:
if (/^degrees?$/i.test(Angle)){
   Token = Func + "*180";
} else if (/^grad$/i.test(Angle)) {
   Token = Func + "*200";
}

This post was edited on 12-05-2006 at 08:47 PM by J-Thread.
12-05-2006 08:45 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
O.P. RE: [?] Calculator in trouble!
Okay, but that doesn't really fix the problem. (And what's wrong with the degrees/grad anyway?)
I'd like to ask Shondoit about it but I didn't see him in months. :(

Maybe someone else? :P
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
12-06-2006 03:38 PM
Profile E-Mail PM Web Find Quote Report
« 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