Notifications
Clear all

[Closed] cant write string in middle of text

Hi Guys i tried to add something to middle of a text file like this :


fs = openFile "D:\Projects\Zaeem\Exports\Map\info.txt" mode:"a+"
skipToString fs "line3"
skipToNextLine fs
print "Hello" to:fs
close fs

my text file is like this :

line1
line2
line3
line4
line5

and i want to add “hello” after line3 text. but it always add the text to the end of the file:

line1
line2
line3
line4
line5
“Hello”

anyone know what is the problem ? thanks

2 Replies

its because mode a+ so changed to this code and now it works :


fs = openFile "D:\Projects\Zaeem\Exports\Map\info.txt" mode:"r+"
skipToString fs "line3"
format "Hello" to:fs
close fs

Hey , actually you don’t need modes , it’s so simple just put your string inside a (/” /”) right inside your main (” “)
for example if you want to format or print a (“Hello World!”) to another string you have to write this code :

Print ” /“Hello World!/” “

The result is : “Hello World!”

that’s it !