Login | Register

Go back and edit script

July 22, 2006, 15:06 by Calle
[loading]
-->
<div style="clear: both;">
file_r = file_text_open_read("myfile.txt";);
file_w = file_text_open_write(“my_edited_file.txt”);

i = 0;
while !(i<b) {
string_r = file_text_read_string(file_r);
file_text_readln(file_r);
if (string_length(add[i])>0) {
file_text_write(file_w,add[i]);
file_text_writeln(file_w);
}
file_text_write(file_w,string_r);
file_text_writeln(file_w);
i += 1;
}

</div>

Sometimes when you got a file, save file or whatever, you might want to add stuff to it, but it is already compiled and the sources from where the original information came are reset. Then you may use this script. It copies all the info over from the old file, but it adds information at lines which you want it to add information at. You decide where to add a line, and you can add as many lines as you wish. This is how you initialize what lines to add:

add[1000] = “”;
add[5] = “This will be added at row five”;
add[10] = “This will be added at row ten”;
add[45] = “This will be added at row 45”;


You can edit this script to delete rows in a similar way. What I basically do is that I copy the entire file over to another file… but you could simply copy the entire file except the line where i equals one of the values you have defined. You could also make this script edit rows which you have defined. I’ll stop at this, but let your imagine flow and originally was a “go back and edit” script, might develop into “the prize awarded file manager FileEdit Pro” or whatever.

Comments

Loading comments... [loading]
.
Users logged in:

game maker articles, game maker examples, game maker tutorials, gmtutorials, game maker questions and answers, game maker crash course, how to create games