Jump to content

How does ReadStringFromFile work?


StealthDick

Recommended Posts

Hello everyone,
I'm facing an issue with the ReturnStringFromFile function in my code. Whenever I call the function, it consistently returns a null value (""). I have confirmed that the file actually exists by using the FileExists function, which returns true.
I'm a bit uncertain about the correct format for the contents of the .txt file that I'm trying to convert into a string. Should the file content be preceded by a $ symbol, or should it be enclosed in quotation marks? I've tried both approaches, including not using either.
I would appreciate any guidance or suggestions to resolve this problem. Thank you in advance for your assistance!

- StealthDick
Link to comment
Share on other sites

You probably have mixed up with two different filepaths. FileExists is relative the Data folder, while ReadStringFromFile is the Game's installation path.

string_var svString = ReadStringFromFile "data\config\The File You Want to Read Strings From.txt" 1 1

The format for the contents of the source file ("The File You Want to Read Strings From.txt") is just a plain text. It goes like this;

Coffee mug
My toaster is the shiniest one in Mojave.
Brahmin milk

And since the sample code only reads the first line from the source file;

svString == "Coffee mug"

Hope this helps.

Link to comment
Share on other sites

Yup, that’s precisely what happened. I just assumed they would follow the same file path logic for some reason. It works like a charm now, I’m very happy with my results. Thank you for the reply, I should have elaborate more in my previous resolution.
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...