How i can do it?
Pages 1
You are not logged in. Please login or register.
AudioGames.net Forum → Developers room → BGT: Get text from txt file to string. How?
Go to the start screen, find bgt, then help
Or if you prefer, open up
"C:\Program Files (x86)\BGT\bgt.chm"
Either way, references/foundation layer/object reference/file. Enter on the topic and f6 to read text. I'm purposely not providing code, as your first step on the programming journey will have to be figuring out the basics
There's an example of this in the file object chapter. It's very easy to do. I strongly recommend you go through the help section. Otherwise, here goes an example.
//I'll skip void main because putting braces seems to break things on the forum.
file f;
string file_contents;
f.open("outfile.txt", "rb");
file_contents=f.read();
And as long as the file in quotes is valid, you now have a string containing the file contents of outfile.txt:
Also, you can eliminate a line by going.
file f;
f.open("outfile.txt", "rb");
string file_contents=f.read();
But I'm overcomplicating ever slightly. I hope this helps!
I mean I got bored enough to make a virtual notepad in bgt (without using audio form) and didn't get passed being able to view the file with your arrow keys because how massively useless the audio form object is, but that's a story and rant for another day.
And yeah, this right here is the basics of saving and loading data, passing the contents of a file to a string. Your supposed to serialise it using dictionaries but aaaaaaaaaaaaa dictionaries! Dictionaries and bgt aren't a combination I would recommend if your after a stable bgt script.
I actually created a note taking program in BGT many moons ago. Note to self, must port to python.
Heh, I just got bored and wanted to see if it could be done without using audio form. Spoiler alert, it can, but it's ever tricky and is likely to end up with massive massive glitches, somewhere. Where? No idea yet. Why? No idea either.
The way I'm doing it is using Arrays and for every true newline I skip empty lines is inserted a new element with the string data. yeah, it's an explanation as vague as trying to read braille sheet music for your first time but there you have it.
AudioGames.net Forum → Developers room → BGT: Get text from txt file to string. How?
Generated in 0.023 seconds (55% PHP - 45% DB) with 11 queries