Copy paste a quote, as a variable

Hi,
I’m looking for a way to copy paste a quote, as a variable.
I have a list of 100 quotes and every time I post on twitter I would like to use one of those quotes.

So basically here is a sample list from text file quotes.txt

  1. Newest and latest
  2. New arrivals
  3. Please welcome

First step, I would like Keyboard Maestro to pick one and save it as variable - quote
Second step, I would like Keyboard Maestro to save-make a note in file quotes.txt of the last used quote, so next time I launch Keyboard Maestro, it would start from the last used quote.
It can be a dash, CURRENT or something in a line of the quote.

  1. Newest and latest
  2. New arrivals (CURRENT)
  3. Please welcome

Any thoughts or working examples,
Thank you!!!

What I would do is simply put the whole lot into a semi-permanent variable, and then pluck off (and delete) the first line each time you want to use it, something like:

Search Variable.kmactions (0.6 KB)

That will pluck off the first line, put it in the variable "Line" and leave all the remaining lines in the variable "Remaining Quotes".

If you really want to have a file or variable with all the quotes and some sort of marker in it, you can do that to, but it is more tricky. Something like:

Keyboard Maestro Actions.kmactions (1.0 KB)

In this case, I needed to add a sentinel to the end of the text, so:

In either case, figuring out when you are off the end of your text is left as a relatively simple exercise.

Simply amazing, I used first solution sine I got lost with second one or my initial plan.

Here is what I got:

  • pick up first line

  • Send first line to the end of the list and update file

Thank you peternlewis!!!

Glad to help. I think you should inestigate the Write to a File action.

Great, thank you,

Is there is a difference in-between Append Text to File and Write Text to FilE?

Most definitely! One adds text to the end of the file. The other overwrites the file if it exists.

Try them with a test file and see what happens.

thank you,

Just tried and YES there is a difference :slight_smile:

Probably a good thing to know the difference, eh? :smile:

OMG, never stop learning !