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
32 / 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 133 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
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[?] Calculator in trouble! - by Matti on 12-05-2006 at 06:34 PM
RE: [?] Calculator in trouble! - by J-Thread on 12-05-2006 at 08:45 PM
RE: [?] Calculator in trouble! - by Matti on 12-06-2006 at 03:38 PM


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