6 registered members (AndrewAMD, Ayumi, degenerate_762, 7th_zorro, VoroneTZ, HoopyDerFrood),
1,268
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: reading and writing strings
[Re: Superku]
#351017
12/21/10 02:48
12/21/10 02:48
|
Joined: Jul 2005
Posts: 1,002 Trier, Deutschland
Nowherebrain
OP
Serious User
|
OP
Serious User
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
|
something to this effect, but it does not work... the texts and the entitys are defined in another script that hold all the variables and filed data..... I'd really like to just read it into one text object from a specific line and stop reading at another line, but....I have no clue how to do that....
function get_quest_file()
{
quest_id = NPC_active.skill11;
if(quest_id == 1000)
{
txt_load(dialogue_txt,"quest_1000.txt");
file_str_write ((temp_txt.pstring)[0],(dialogue_txt.pstring)[3]);
file_str_write ((temp_txt.pstring)[1],(dialogue_txt.pstring)[4]);
file_str_write ((temp_txt.pstring)[2],(dialogue_txt.pstring)[5]);
}
}
Last edited by Nowherebrain; 12/21/10 02:55.
|
|
|
Re: reading and writing strings
[Re: Nowherebrain]
#351080
12/21/10 18:08
12/21/10 18:08
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
fogman posted a good solution some weeks ago: "fileparser" He wrote two functions, one for strings and one for variables. file_seek sets the reading cursor to the beginning of the file, file_find, finds the string, and the line after that reads the string or the variable after the found string.
|
|
|
Re: reading and writing strings
[Re: Pappenheimer]
#351081
12/21/10 18:15
12/21/10 18:15
|
Joined: Apr 2005
Posts: 4,506 Germany
fogman
Expert
|
Expert
Joined: Apr 2005
Posts: 4,506
Germany
|
You have to define gvFileParserHandle global when you want to use this snippet:
var gvFileParserHandle = 0; var gvVideoMode; . . . function ReadVar() { gvFileParserHandle = file_open_read("yourfilename.txt"); gvVideoMode = FileparserVar("VIDEO_MODE = "); file_close(gvFileParserHandle); }
In the textfile you would write:
VIDEO_MODE = 8
The function will read the value right after the defined search string.
You should also take a look at strio.c in the GS include folder.
Last edited by fogman; 12/21/10 18:21.
no science involved
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|