Re: [DQSD-Users] Calculator problem: comma vs. period

2003-02-04 Thread Glenn Carr
Yeah.  I think so.  I just gave Greg CVS access, so he's gonna check it in.

BTW, sorry for no new release yet.  I've been trying to spin too many plates,
and haven't made the time to build one.  I assume there's nothing major pending
('cept the restructure which I'm supposed to be working on --argh)... is that
correct?

Glenn
[reply to the devel list]

- Original Message -
From: "Monty Scroggins" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 04, 2003 8:19 AM
Subject: RE: [DQSD-Users] Calculator problem: comma vs. period


> Should these changes be checked in to cvs?  If preferences.js were modified
> to set a deault calculatorDecimal of ".", the toolbar would operate as it
> does now, and anyone wanting the comma used as a separator could override
> the setting in localprefs.js.   Or is this an isolated case where the
> localization of Greg's machine isnt functioning properly?
>
> Monty
>
>
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]]On Behalf Of Krohne
> > Gregory Contr AFRC/SCOS
> > Sent: Thursday, January 30, 2003 3:31 PM
> > To: '[EMAIL PROTECTED]'
> > Subject: RE: [DQSD-Users] Calculator problem: comma vs. period
> >
> >
> > Okay, let's make it a little less cheesy. Add a line to localprefs.js that
> > defines a decimal separator character; call it calculatorDecimal:
> >
> > 
> > /* Calculator decimal separator character.
> > *  Value can be almost any character not used for computation.
> > *  Default value is '.' (period), if no value is set
> > */
> > calculatorDecimal = ",";
> >
> > In calculate.js, add a little more code to check for variable
> > calculatorDecimal and use it:
> >
> > 
> >  9if (typeof calculatorDecimal != "undefined" && calculatorDecimal !=
> > "") {
> > 10var re = new RegExp("\\" + calculatorDecimal, "g");
> > 11expr = expr.replace(re, ".");
> > 12}
> >
> > Lines 24 & 25 have been inserted before original line 24 (now 26).
> >
> > 24 if (typeof calculatorDecimal != "undefined" &&
> > calculatorDecimal != "")
> > 25 answer = answer.toString().replace(/\./g,
> > calculatorDecimal);
> > 26 setSearchWindowText(answer, true);
> >
> > Now, we can use comma for a decimal separator, and the answer will use the
> > comma, too. I included a sample localprefs.js and a modified calculate.js
> > file at the bottom of this message. Of course, we still have the same
> > problem with updates: our new calculate.js will be overwritten. Moreover,
> > this fix shouldn't be necessary in the first place: the JavaScript math
> > functions should be sufficiently region-aware to format numbers correctly.
> > It's possible that we could use the javascript function
> > navigator.systemLanguage to make a best guess about how to format numbers.
> > I'll submit a feature request to include this particular change,
> > and perhaps
> > another feature request to support regional settings in general.
> >
> > Regards,
> > Gregory Krohne
> >
> > > From: "Monty Scroggins" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Subject: RE: [DQSD-Users] Calculator problem: comma vs. period
> > > Date: Thu, 30 Jan 2003 10:02:28 -0600
> > > Reply-To: [EMAIL PROTECTED]
> > >
> > > hmmmThis is cheesy workaround for this problem, but you
> > > could maybe add
> > > this line - var expr =3D expr.replace(/\,/g, ".");  at line 9
> > > of calculat= e.js. This replaces any commas with decimals in
> > > the math expression..
> > >
> > > Of course every toolbar upgrade will overwrite calculate.js,
> > > so you will need to make this change again if you upgrade
> > >
> > > Monty
> > >
> > >
> > > >
> > > > This is a real problem, becouse almost everywhere else it's a comma,
> > > > like 234,5+15 which gives weird results like 20??
> > > >
> > > > Is this a localized problem, becouse I live in Finland and here the
> > > > decimal-separator is always a comma?
> > > >
> > > > If I copy&paste some numbers, I have to change the commas to periods
> > > > for the calculator to work.
> > > > Is there any solution that could fix the problem?
> > > >
> > > > B

RE: [DQSD-Users] Calculator problem: comma vs. period

2003-02-04 Thread Monty Scroggins
Should these changes be checked in to cvs?  If preferences.js were modified
to set a deault calculatorDecimal of ".", the toolbar would operate as it
does now, and anyone wanting the comma used as a separator could override
the setting in localprefs.js.   Or is this an isolated case where the
localization of Greg's machine isnt functioning properly?

Monty


> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Krohne
> Gregory Contr AFRC/SCOS
> Sent: Thursday, January 30, 2003 3:31 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE: [DQSD-Users] Calculator problem: comma vs. period
>
>
> Okay, let's make it a little less cheesy. Add a line to localprefs.js that
> defines a decimal separator character; call it calculatorDecimal:
>
> 
> /* Calculator decimal separator character.
> *  Value can be almost any character not used for computation.
> *  Default value is '.' (period), if no value is set
> */
> calculatorDecimal = ",";
>
> In calculate.js, add a little more code to check for variable
> calculatorDecimal and use it:
>
> 
>  9if (typeof calculatorDecimal != "undefined" && calculatorDecimal !=
> "") {
> 10var re = new RegExp("\\" + calculatorDecimal, "g");
> 11expr = expr.replace(re, ".");
> 12}
>
> Lines 24 & 25 have been inserted before original line 24 (now 26).
>
> 24if (typeof calculatorDecimal != "undefined" &&
> calculatorDecimal != "")
> 25answer = answer.toString().replace(/\./g,
> calculatorDecimal);
> 26setSearchWindowText(answer, true);
>
> Now, we can use comma for a decimal separator, and the answer will use the
> comma, too. I included a sample localprefs.js and a modified calculate.js
> file at the bottom of this message. Of course, we still have the same
> problem with updates: our new calculate.js will be overwritten. Moreover,
> this fix shouldn't be necessary in the first place: the JavaScript math
> functions should be sufficiently region-aware to format numbers correctly.
> It's possible that we could use the javascript function
> navigator.systemLanguage to make a best guess about how to format numbers.
> I'll submit a feature request to include this particular change,
> and perhaps
> another feature request to support regional settings in general.
>
> Regards,
> Gregory Krohne
>
> > From: "Monty Scroggins" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Subject: RE: [DQSD-Users] Calculator problem: comma vs. period
> > Date: Thu, 30 Jan 2003 10:02:28 -0600
> > Reply-To: [EMAIL PROTECTED]
> >
> > hmmmThis is cheesy workaround for this problem, but you
> > could maybe add
> > this line - var expr =3D expr.replace(/\,/g, ".");  at line 9
> > of calculat= e.js. This replaces any commas with decimals in
> > the math expression..
> >
> > Of course every toolbar upgrade will overwrite calculate.js,
> > so you will need to make this change again if you upgrade
> >
> > Monty
> >
> >
> > >
> > > This is a real problem, becouse almost everywhere else it's a comma,
> > > like 234,5+15 which gives weird results like 20??
> > >
> > > Is this a localized problem, becouse I live in Finland and here the
> > > decimal-separator is always a comma?
> > >
> > > If I copy&paste some numbers, I have to change the commas to periods
> > > for the calculator to work.
> > > Is there any solution that could fix the problem?
> > >
> > > Best regards,
> > > Janne Riihim=E4ki
>
> /* localprefs.js
> *
> * Add preferences here to keep them from being overwritten on upgrades.
> *
> * Use preferences.js as a guide, copying settings from that
> * file to this file, and then modifying them to suit your
> * personal taste.
> */
>
> /* Calculator decimal separator character.
> *  Value can be almost any character not used for computation.
> *  Default value is '.' (period), if no value is set
> */
> calculatorDecimal = ",";
>
> /* calculate.js
> * offline calculator
> */
> function calculate(expr)
> {
>   if (expr.match(/=ERR$/))
> return;
>
>   try
>   {
> if (typeof calculatorDecimal != "undefined" &&
> calculatorDecimal != "")
> {
>   var re = new RegExp("\\" + calculatorDecimal, "g");
>   expr = expr.replace(re, ".");
> }
> w

RE: [DQSD-Users] Calculator problem: comma vs. period

2003-01-30 Thread Krohne Gregory Contr AFRC/SCOS
Okay, let's make it a little less cheesy. Add a line to localprefs.js that
defines a decimal separator character; call it calculatorDecimal:


/* Calculator decimal separator character.
*  Value can be almost any character not used for computation.
*  Default value is '.' (period), if no value is set
*/
calculatorDecimal = ",";

In calculate.js, add a little more code to check for variable
calculatorDecimal and use it:


 9if (typeof calculatorDecimal != "undefined" && calculatorDecimal !=
"") {
10  var re = new RegExp("\\" + calculatorDecimal, "g");
11  expr = expr.replace(re, ".");
12}

Lines 24 & 25 have been inserted before original line 24 (now 26).

24  if (typeof calculatorDecimal != "undefined" &&
calculatorDecimal != "")
25  answer = answer.toString().replace(/\./g,
calculatorDecimal);
26  setSearchWindowText(answer, true);

Now, we can use comma for a decimal separator, and the answer will use the
comma, too. I included a sample localprefs.js and a modified calculate.js
file at the bottom of this message. Of course, we still have the same
problem with updates: our new calculate.js will be overwritten. Moreover,
this fix shouldn't be necessary in the first place: the JavaScript math
functions should be sufficiently region-aware to format numbers correctly.
It's possible that we could use the javascript function
navigator.systemLanguage to make a best guess about how to format numbers.
I'll submit a feature request to include this particular change, and perhaps
another feature request to support regional settings in general.

Regards,
Gregory Krohne

> From: "Monty Scroggins" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Subject: RE: [DQSD-Users] Calculator problem: comma vs. period
> Date: Thu, 30 Jan 2003 10:02:28 -0600
> Reply-To: [EMAIL PROTECTED]
> 
> hmmmThis is cheesy workaround for this problem, but you 
> could maybe add
> this line - var expr =3D expr.replace(/\,/g, ".");  at line 9
> of calculat= e.js. This replaces any commas with decimals in 
> the math expression..
> 
> Of course every toolbar upgrade will overwrite calculate.js,
> so you will need to make this change again if you upgrade
> 
> Monty
> 
> 
> >
> > This is a real problem, becouse almost everywhere else it's a comma,
> > like 234,5+15 which gives weird results like 20??
> >
> > Is this a localized problem, becouse I live in Finland and here the
> > decimal-separator is always a comma?
> >
> > If I copy&paste some numbers, I have to change the commas to periods
> > for the calculator to work.
> > Is there any solution that could fix the problem?
> >
> > Best regards,
> > Janne Riihim=E4ki

/* localprefs.js
*
* Add preferences here to keep them from being overwritten on upgrades.
* 
* Use preferences.js as a guide, copying settings from that
* file to this file, and then modifying them to suit your
* personal taste.
*/

/* Calculator decimal separator character.
*  Value can be almost any character not used for computation.
*  Default value is '.' (period), if no value is set
*/
calculatorDecimal = ",";

/* calculate.js
* offline calculator
*/
function calculate(expr)
{
  if (expr.match(/=ERR$/))
return;

  try
  {
if (typeof calculatorDecimal != "undefined" && calculatorDecimal != "")
{
var re = new RegExp("\\" + calculatorDecimal, "g");
expr = expr.replace(re, ".");
}
with(Math)
{
  var answer = eval(expr);
  if (typeof(answer) == "number")
  {
// for the sake of pretty decimal numbers,
// round numbers that are very close to a ten-millionth
if (abs(answer) >= 0.001 &&
abs(round(answer * 1e+7) - answer * 1e+7) < 0.001)
  answer = round(answer * 1e+7)/1e+7;
  }
  if (typeof calculatorDecimal != "undefined" && calculatorDecimal
!= "")
answer = answer.toString().replace(/\./g,
calculatorDecimal);
  setSearchWindowText(answer, true);
}
  }
  catch (exception)
  {
setSearchWindowText(expr + "=ERR=", true);
  }

  savevars();
}

// based log functions
function log10(n) { return ln(n)/ln10; }
function log2(n) { return ln(n)/ln2; }

// hex conversion for use in calculator
function hex(i)
{
  hexChars = "0123456789abcdef";
  var h = "";
  var n = 256;

  while (i < 0)
  {
 if (i + n / 16 > 0) { i += n; break; }
 n = n * n;
  }

  while (i > 0)
  {
 h = hexChars.charAt(i % 16) + h;
 i = Math.floor(i / 16);
  }

  if (h == "")
 h = &q

RE: [DQSD-Users] Calculator problem: comma vs. period

2003-01-30 Thread Monty Scroggins
hmmmThis is cheesy workaround for this problem, but you could maybe add
this line - var expr = expr.replace(/\,/g, ".");  at line 9 of calculate.js.
This replaces any commas with decimals in the math expression..

Of course every toolbar upgrade will overwrite calculate.js, so you will
need to make this change again if you upgrade

Monty


>
> This is a real problem, becouse almost everywhere else it's a comma,
> like 234,5+15 which gives weird results like 20??
>
> Is this a localized problem, becouse I live in Finland and here the
> decimal-separator is always a comma?
>
> If I copy&paste some numbers, I have to change the commas to periods for
> the calculator to work.
> Is there any solution that could fix the problem?
>
> Best regards,
> Janne Riihimäki
>
>
>
>
>



---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
To unsubscribe visit:
https://lists.sourceforge.net/lists/listinfo/dqsd-users
[EMAIL PROTECTED]
http://sourceforge.net/mailarchive/forum.php?forum_id†01



[DQSD-Users] Calculator problem: comma vs. period

2003-01-30 Thread naghris
Hi,

This excellent little helper is a miracle! But one thing has annoyed me
for a while and I just wondered if there is an easy solution for it. I
use the calc-function very much, becouse it's much faster than to start
an calc-application every time I have to calculate something. But when I
use decimals, I have to use period instead of comma, like 234.5+15=249.5

This is a real problem, becouse almost everywhere else it's a comma,
like 234,5+15 which gives weird results like 20??

Is this a localized problem, becouse I live in Finland and here the
decimal-separator is always a comma? 

If I copy&paste some numbers, I have to change the commas to periods for
the calculator to work. 
Is there any solution that could fix the problem?

Best regards,
Janne Riihimäki





---
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
___
To unsubscribe visit:
https://lists.sourceforge.net/lists/listinfo/dqsd-users
[EMAIL PROTECTED]
http://sourceforge.net/mailarchive/forum.php?forum_id†01