Hi. In my file, I have a number. Let's say I make that number different in bgt, and I want to update that number in the file. How would I replace the old number with the new one without modifying anything else before or after that number?
Pages 1
You are not logged in. Please login or register.
AudioGames.net Forum → Developers room → removing data from a file in bgt
Hi. In my file, I have a number. Let's say I make that number different in bgt, and I want to update that number in the file. How would I replace the old number with the new one without modifying anything else before or after that number?
Open the file, make string that holds the text of that file, and parse the file with string_split. If you're number is the only instance, you could do string_contains().
It's been a while since I used BGT, but the general process will be the same whatever language you use.
Read the file into a list array.
Change the data in the array you want.
Then replace the file contents with the array.
That, to me, seems to be the safest way.
That's kind of the point here. Once you read in the data from the file and change it in your program then overwrite the old file with the new data, you've deleted the old and replaced it with the new.
1. Open file
2. read file contents into a variable of some sort (probably text/string or an array of that)
3. Manipulate the contents in that variable
4. Then write variable back to the file making sure your overwriting the previous contents (not appending)
5. Close the file
AudioGames.net Forum → Developers room → removing data from a file in bgt
Generated in 0.018 seconds (43% PHP - 57% DB) with 11 queries