StealthDick Posted June 10, 2023 Share Posted June 10, 2023 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 More sharing options...
StealthDick Posted June 12, 2023 Author Share Posted June 12, 2023 The file path I was using was "Config\MyFolder\MyFile.txt", it was supposed to be "Data\Config\MyFolder\MyFile.txt" Link to comment Share on other sites More sharing options...
ebizoe Posted June 16, 2023 Share Posted June 16, 2023 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 1The 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 mugMy toaster is the shiniest one in Mojave.Brahmin milkAnd 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 More sharing options...
StealthDick Posted June 16, 2023 Author Share Posted June 16, 2023 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 More sharing options...
Recommended Posts