Jump to content

Using Multiple Text Manipulation Tasks with Single Query


Recommended Posts

Posted (edited)

I wanted to create a automation task workflow that does both a word and a character count on a selected text string. I found Stephen Christy's excellent workflow for word count. With this as a model, I created a character count workflow and then my next version had a dialog box asking user to choose word or character count. Both worked great.

 

image.thumb.png.c04c1d1aef5e3e1a9d62edba4e8e42b1.png

 

However, if I want a workflow that displays both, I can't get it to work. I tried running the automation tasks sequentially and then in parallel, but both failed in different ways. I think running these sequentially makes sense, conceptually, but I think the input gets stepped on so it doesn't exist for the second automation task.

 

How can I maintain the same text input for for both text automation tasks?

 

Thanks.

Edited by DrDannySands
clarification
Posted

In essence:

  • Use the Arg and Vars utility at the start of the workflow to save the selected text as a variable. Pass it through to the first Automation Task.
  • Use the Arg and Vars utility after that task to save the result (i.e., count of words, or count of characters) as a variable and to pass to the next Automation Task the text variable you saved in the first step.
  • Link to the next Automation Task to count whatever you didn't already count and again save the output to another variable.
  • You could use a Dialog Conditional to display the result—using the two saved variables—or you could add them to the clipboard displayed as you wish (again using the two saved variables).

I appreciate this may all sound a little complicated but it's fine once you get the hang of it! If you look at my New folder workflow in the Alfred Gallery you'll get a better idea of how saving and using variables works.

 

Stephen

Posted
2 hours ago, Stephen_C said:

Use the Arg and Vars utility at the start of the workflow to save the selected text as a variable. Pass it through to the first Automation Task.

 

Thanks for the response, Stephen. I thought about that, but I thought the Automation Tasks take {query} as an input--how can I make the Automation Task take a variable as an input?

Posted

Ah never mind. I figured it out. I didn't realize I could set {query} by adding 

 

{query}={var:QueryText}

 

in the Arguments section right before the second text processing Automation Task.

 

Now it works perfectly. 😀

Posted

I'm glad it's working. However, all you need really to do before the second text processing Automation Task is this (assuming you've previously saved the QueryText variable, of course):

 

CleanShot-CleanShot-29-03-2023-at05_47.08@2x.thumb.png.4f422091f345a2cb59ced93ba750ab68.png

 

You don't need the {query}= part.

 

Stephen

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...