Jump to content

Will-i-am

Member
  • Posts

    12
  • Joined

  • Last visited

Reputation Activity

  1. Like
    Will-i-am reacted to Andrew in Play Sound Output   
    @Will-i-am not right now, but there will be in a future release of Alfred 3  ^A
  2. Like
    Will-i-am reacted to deanishe in Prompt in Workflow before opening...   
    You could put a dialog box after the File Filter, but the "normal" Alfred way is simpler and faster.
  3. Like
    Will-i-am reacted to deanishe in Prompt in Workflow before opening...   
    That's not how Alfred works. Click on one of the connections and assign a modifier key, e.g. ⌘
     
    The you hit ↩ to open file or ⌘↩ to reveal in Finder.
  4. Like
    Will-i-am reacted to rice.shawn in Coding clean up   
    After you install the workflow, just open it up and look at the `script-filter.php`. You'll see that I've included a library called "Alphred" that I wrote that makes writing workflows in PHP much, much easier, and so that is what controls the output for the script filter. Here, the library just easily creates the XML that Alfred reads.
     
    The text to date functionality (for things like "now" or "tomorrow" or "+1 year") are built into PHP's date functionality. More specifically, they're built into the function `strtotime`, and so that does a lot of the heavy lifting.
     
    The actual conversion from Arabic to Roman numerals is done by breaking the date string (31/3/1999) into an array and then using an `array_filter` (which just applies the same function to each part). So, all we needed was a single function to convert an Arabic number to a Roman numeral.
     
    The function that does that is here:
    function toRoman( $integer ) { $output = ''; $conversion = [ 'M' => 1000, 'CM'=> 900, 'D'=>500, 'CD'=>400, 'C'=>100, 'XC'=>90, 'L'=>50, 'XL'=>40, 'X'=>10, 'IX'=>9, 'V'=>5, 'IV'=>4, 'I'=>1 ]; while ( $integer > 0 ) : foreach ( $conversion as $roman => $arabic ) : if ( $integer >= $arabic ) { $integer -= $arabic; $output .= $roman; break; } endforeach; endwhile; return $output; } So, basically it takes an associative array that defines the translations between Arabic and Roman and then just uses two loops to modify the input value while constructing an output string. Each time it adds onto the string, it removes the equivalent value from the input integer and just keeps going until the integer reaches 0 and then returns the string.
     
    Hopefully the explanation helps.
     
    I did decide to make it a script filter rather than using an Applescript input box because it makes it easier to manipulate the values quickly and see the results.
  5. Like
    Will-i-am reacted to rice.shawn in Coding clean up   
    I re-coded it in PHP and dropped it in a simple workflow that you can download here: https://www.dropbox.com/s/hihr5zl054wdq5u/Roman%20Date.alfredworkflow?dl=0.
     
    It works as a script filter and uses PHP's date parser, so you can do things like "rd now" and "rd tomorrow" and "rd next friday" and "rd -1000 years" as well as "Oct 29 1993" or "10/29/1993".
     
    Currently, if you press enter, it just displays it as large text.
  6. Like
    Will-i-am reacted to jdfwarrior in Coding clean up   
    Bill, I moved this into the workflow help section of the forums to get it a little more exposure.
     
    Are you needing help with something in particular on this or simply looking for pointers?
×
×
  • Create New...