2019-02-14 07:45:31

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?

2019-02-14 14:01:44

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().

Ivan M. Soto.
Feel free to check out my work and services.
http://ims-productions.com

2019-02-14 14:10:09

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.

***
You can follow me on twitter @s_luttrell and an almost never used Facebook account at skluttrell.

2019-02-14 16:44:02

But how do I replace the new number while deleting the old one?

2019-02-14 17:16:00

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

***
You can follow me on twitter @s_luttrell and an almost never used Facebook account at skluttrell.