DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: [FCalc] Variable increment bug  (Read 8,135 times)

d4ni

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 129
[FCalc] Variable increment bug
« on: January 19, 2009, 04:27 PM »
Hi mouser,

I believe I have identified a (pretty obvious) bug while incrementing a variable which has been created using FCalc. If I want to add 1 to a variable x, is there any other way than using fc x = x+1 or fc x = (x+1)? The += operator is not supported I noticed, so I figured this was the way to go. However, the variable x actually gets the value x+2.

To reproduce:
1. Launch FCalc using its regex
2. Type 'x = 0'
3. Type 'x = (x+1)'
4. Type 'x' to see the result.

The result is supposed to be 1, but instead is 2. This happens all the time.

I think part of the bug is the fact you can alter variables *without* pressing the enter key. For example, I can type:
1. 'x = 0' [ENTER]
2. 'x = 5' // But then remove the line using backspace, perhaps I made an error. I *did not* press [ENTER] here.

Now, however, x *did* in fact change to 5. Which, imho, it should *not* do.

::important edit

It seems if I want to increment integer x with the constant n using the notation x = (x+n), it is somehow parsed to x = x + 2n. In the case of incrementing by 1, this results in an increment by 2. If I increment by 10, however, x will be incremented by 20 instead.
« Last Edit: January 19, 2009, 04:30 PM by d4ni »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,931
    • Gathering Badge
    • Plugin Coding Medal
    • Participated in NANY Challenge Seventeen Times
    • Cody Award
    • Coding Snacks
    • Volunteers/Staff
Re: [FCalc] Variable increment bug
« Reply #1 on: January 19, 2009, 08:33 PM »
you are right! wow that's weird. i'll fix.
however i might point you to jscalc by czb which is a newer calculator plugin for farr with some additional very cool features.

d4ni

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 129
Re: [FCalc] Variable increment bug
« Reply #2 on: January 19, 2009, 11:41 PM »
Ofcourse I'm right ;) j/k

I just checked jscalc out for a bit and it certainly is nice, thanks for the tip. It actually does support +=, *= and /=, sweet!

d4ni

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 129
Re: [FCalc] Variable increment bug
« Reply #3 on: August 14, 2009, 09:28 PM »
Just a heads up, I noticed the bug is still around ;)

Original address: https://www.donationcoder.com/forum/index.php?topic=16669.0