DrDannySands Posted March 28, 2023 Posted March 28, 2023 (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. 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 March 28, 2023 by DrDannySands clarification
Stephen_C Posted March 28, 2023 Posted March 28, 2023 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
DrDannySands Posted March 28, 2023 Author Posted March 28, 2023 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?
DrDannySands Posted March 29, 2023 Author Posted March 29, 2023 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. 😀
Stephen_C Posted March 29, 2023 Posted March 29, 2023 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): You don't need the {query}= part. Stephen vitor 1
DrDannySands Posted March 29, 2023 Author Posted March 29, 2023 Brilliant! Thank you. I really love learning how to be more productive with Alfred and benefiting from its awesome community of developers. vitor and Vero 2
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now