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: built-in calculator ?  (Read 7,779 times)

pixeline

  • Participant
  • Joined in 2008
  • *
  • Posts: 3
built-in calculator ?
« on: December 03, 2008, 09:39 AM »
Hi guys,

i recently switched from Launchy to FARR and so far really like it, especially for its low use of system resources. Yet, I do miss the possibility to simply type 5+10= and have 15 displayed. Is it not implemented or am i overlooking something?

thanks for this great software !

Alex

justice

  • Solve issues simply.
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,898
    • Participated in NANY Challenge Four Times
    • Cody Award
    • Coding Snacks
    • DJ Badge - DJ
Re: built-in calculator ?
« Reply #1 on: December 03, 2008, 09:45 AM »
There's a plugin Fcalc that you can install to do this, you'd type
fc 5+10 and press enter.

Easiest way to get this is to install this plugin and all other ones via DcUpdater if you have that installed. it will list them in the second tab.

pixeline

  • Participant
  • Joined in 2008
  • *
  • Posts: 3
Re: built-in calculator ?
« Reply #2 on: December 03, 2008, 09:52 AM »
works super well! thanks a lot justice !

any easy way to tweak it so i don't even have to type "fc" beforehand ?

d4ni

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 129
Re: built-in calculator ?
« Reply #3 on: December 03, 2008, 01:15 PM »
Pretty sure you have to type fc and there is no real way around this. Well, you can shorten it to, say, the '=' sign or something.

justice

  • Solve issues simply.
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,898
    • Participated in NANY Challenge Four Times
    • Cody Award
    • Coding Snacks
    • DJ Badge - DJ
Re: built-in calculator ?
« Reply #4 on: December 03, 2008, 01:17 PM »
Go to options -> Hotkeys
Edit or create a new hotkey and add fc followed by a space the following into the 'Text for search edit box', you can then launch FARR with FC already typed in.

pixeline

  • Participant
  • Joined in 2008
  • *
  • Posts: 3
Re: built-in calculator ?
« Reply #5 on: December 03, 2008, 01:30 PM »
super, works a breeze. thanks a lot !

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: built-in calculator ?
« Reply #6 on: December 03, 2008, 03:44 PM »
there is an easy way to do what you want, dc member Joto did this earlier and meant to post it but didn't.

basically you make an alias in the options which matches numerical expressions, and has the result:
dosearch fc $$1

the tricky part is defining the regular expression and i'm afraid my regex skills are a bit rusty.

maybe someone can figure out a good regex for it and post.



ps. dc member czb has recently written a more powerful calculator plugin for farr which uses javascript; one real nice thing about it is you can add custom functions really easily. i think he'll be posting it very soon.

d4ni

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 129
Re: built-in calculator ?
« Reply #7 on: December 03, 2008, 09:02 PM »
This regexp:

(\d+(?:[+-/*^]\d+)+)


Allows simple expressions, not using any parenthesis but that could be easily fixed I assume. Not much time now :) This way you can use +, -, *, /, and ^. Just add more to the regexp.

Dont put spaces between the numbers and operators, regexp doesn't allow that yet but again, can be added. Gotta go now, mb I'll enhance it later tonight.


--EDIT

Slightly improved:
(\(?\s?\d+(?:\s?[+-/*^]\s?\(?\s?\d+\s?\)?)+).

You can import it directly using this:
Code
1000>>>FCalc>->Calculate $$1 | dosearch fc $$1>+>(\(?\s?\d+(?:\s?[+-/*^]\s?\(?\s?\d+\s?\)?)+)

This allows both parenthesis and spacing between numbers and operators. For example, this is all valid input:
1 + ( 5 * 5 )
1 + (5 * 5)
1 + (5*5)
1+(5*5)

etc.

You can ofcourse expand the equation with more operands and operators. Please note I currently do not allow for more than 1 space, but it's easily adjusted by editing each \s? (whitespace, 1 or 0 times), to \s* (whitespace, zero or more times).

This should be sufficient for most input imho, I hope I am not forgetting something here :). Feel free to improve or (dramatically) change. Not gonna spend a lot more time on this; you can probably increase the amount of available operators (I have only included 5 now) :)
« Last Edit: December 03, 2008, 11:05 PM by d4ni »

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