.TXT to variable?

Hello everyone, I am writing this to know if it is possible a script that writes from a txt file to a specific variable.

I will explain it better.
there are variables that you can put text, example:
Code:
$game_variables[6] = "Text of Variable"

and there are scripts/codes that allow you to create and read txt files, such as:
Code:
File.open ("filename.txt", "a") {| f | f.write ("File text \ nThe second line.")}

the command "a" and "w" I understand that it is for write to the file.
and the command "r" is for read the file.

With this in mind, I would like to see if when reading a file, the same text of the file that is being read (the text that it has) can be transferred in a variable.

that is, if one writes in the txt, and what is written there, it is transferred to the game by variable.

that can be possible?

PS: I don't know if the script to read the txt could read lines separately or it will read everything together.
Please search the forum for a script called "SES External Text", that basically does what you want.
It will allow you to create text files outside the RM-editor that are then read and analysed by that script, and the script provides functions to replace "keys" used in show text with the longer texts stored in those external text files.

It is not exactly what you asked, but the script contains all functions you would need to place one of those texts into a variable as well.

Original thread: https://forums.rpgmakerweb.com/threads/txt-to-variable.119163/