Jump to content

Math / Number Manipulation Workflow Help


Recommended Posts

Posted

Hello all,

 

I would like to create a workflow to manipulate some numbers (for example, a decimal to hexadecimal converter). I currently have a keyword as an input, and a copy to clipboard as an output. I want to write the script between the input and the output in Python, but I'm having trouble. How do you pass parameters into the Python script, and how do you return a result to send to the output action?

 

Thanks in advance!

Posted (edited)

Take a look at this : http://www.alfredforum.com/topic/4570-rpn-calculator/?hl=calculator . It uses a script filter in an external python script stored in the workflow folder to give live results while it calculates, and implements an rpn calculator in < 50 lines of code thanks to the hard work of others.....If you're working in Python you definitely want to be using deanishe's workflow library. It's well worth downloading the library and working through the tutorials (a pinboard workflow).

Edited by dfay
Posted

To add to what dfay said, it's pretty damn simple to convert decimal to hexadecimal/binary/etc. in Python:
 

# convert query to an integer
dec = int("{query}")
# base 2
binary = bin(dec)
# base 8
octal = oct(dec)
# base 16
hexadecimal = hex(dec)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...