Script for random quotes not working anymore

Share your favorite FastKeys commands
Post Reply
User avatar
cyrilmalka
Posts: 7
Joined: Feb 22nd, ’19, 02:54

Post by cyrilmalka » Dec 21st, ’23, 15:09

Hello,

Once upon a time, I needed a script to add a random quote from a file at the bottom of my mail. I got some help from here and I used the method nr2 as stated in this thread: viewtopic.php?t=855

But I got a new computer, and now, this is not working anymore. Instead of just picking up one quote, the script goes on and reads and executes whatever it can execute from the text file.

Here is the script:

FileRead, List, D:\Dropbox\Dokumenter\underskrifter\tags.txt
Sort, List, Random
Send, % SubStr(List, 1, InStr(List, "`r`n")-1)

What can I do to make it stop after it writes the line from the file?

Thanks in advance for your answers.

Regards,

Cyril
User avatar
Tom
Posts: 897
Joined: Nov 24th, ’15, 23:39

Post by Tom » Dec 21st, ’23, 23:22

Please make sure the text file contains quotes, each in a new line.
Maybe your file is formatted differently, in this can you may need to change the last line to

Send, % SubStr(List, 1, InStr(List, "`n")-1)
User avatar
cyrilmalka
Posts: 7
Joined: Feb 22nd, ’19, 02:54

Post by cyrilmalka » Dec 22nd, ’23, 06:43

Hello, Tom,

Thank you for your answer.

Yes, the file containing the quotes contains one quote per line. It has been working fine until now. I didn't touch anything. I bought a new computer, exported my Fastkeys to the new computer.

The txt-file is the same I just copied it from one computer to an other.

I tried the change you suggested, it didn't change anything.

If I start the script on Notepad++ for example, it writes all the quotes, one pr. line and after a while, if I don't touch anything, it writes gibberish.

I don't understand what happens at all.

Here is a 50 seconds video so you can see what happens (if it helps): https://somup.com/c0l31GkIiO

There is the same kind of code twice: Once from one file for the promotion, and then the second one with the taglines. The problem happens only with the tagline.

I write "sig+" which contains this:

--
Amicalement,

Cyril

Cyril Malka sur Instagram => http://instagram.com/cyril_malka

%CODE_kurser%

... %CODE_tagline%


And then, what you see in the video happens.


Regards,

Cyril
User avatar
Tom
Posts: 897
Joined: Nov 24th, ’15, 23:39

Post by Tom » Dec 22nd, ’23, 13:15

I tested it again on my end and it works as expected. I see you have another code in CODE_kurser macro. Check it out, maybe this is causing the trouble.
User avatar
cyrilmalka
Posts: 7
Joined: Feb 22nd, ’19, 02:54

Post by cyrilmalka » Dec 24th, ’23, 09:26

Hello, Tom,

Thanks for your help.

I tried to remove the first one. It didn't help.

They are identical codes, just two different .txt files. The one works (kurser), the other didn't (tags).

So I finally copied the text from the text-file that didn't work (tags) on a copy of the text-file that worked (kurser) and it works again.

Apparently there must have been something in the one text file that went wrong. It was corrupted in a way.

Now it works.

Thanks for your time.

Regards,

Cyril
Post Reply