Gamestudio Links
Zorro Links
Newest Posts
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Trading Journey
by 7th_zorro. 04/27/24 04:42
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Akow, AndrewAMD, Quad), 733 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
reading and writing strings #350972
12/20/10 18:09
12/20/10 18:09
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Nowherebrain Offline OP
Serious User
Nowherebrain  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
I'm not so new but I am having trouble, and I saw this as something that could go in the beginner area, as I am stumped...
does anyone have an example or know of an example of reading specific strings from a file into specific strings of a text?
I can load a text using "txt_load" and I can read and write to TEXT*.pstring[x], but getting very specific pstring to pstring I am having issues. any example would be helpful.


Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/
Re: reading and writing strings [Re: Nowherebrain] #350983
12/20/10 18:47
12/20/10 18:47
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Please give an example of what you are trying to do.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
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 Offline OP
Serious User
Nowherebrain  Offline 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....
Code:
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.

Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/
Re: reading and writing strings [Re: Nowherebrain] #351048
12/21/10 11:53
12/21/10 11:53
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
wouldn't you juse use str_cpy() when copy data from one text to another.

If you specify it is what you're doing there probably is an easier way to do it rather than transferring the text twice.

Re: reading and writing strings [Re: MrGuest] #351058
12/21/10 14:43
12/21/10 14:43
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Nowherebrain Offline OP
Serious User
Nowherebrain  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
yes probably, but I am storing quests in separate files, and....and.......I had not even thought about str_cpy...I always have to make things more difficult...I will rewrite the function. Thank you.


Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/
Re: reading and writing strings [Re: Nowherebrain] #351071
12/21/10 16:20
12/21/10 16:20
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Nowherebrain Offline OP
Serious User
Nowherebrain  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
well, I was able to get it to work by loading a text and just setting the text objects size with wrap flag set, then I don't need to do line feeds...but I would still like to use string compare so I can read from specific points, but I think I can figure it out....


Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/
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 Offline
Senior Expert
Pappenheimer  Offline
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
F
fogman Offline
Expert
fogman  Offline
Expert
F

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
Re: reading and writing strings [Re: fogman] #351099
12/21/10 20:37
12/21/10 20:37
Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
Nowherebrain Offline OP
Serious User
Nowherebrain  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,002
Trier, Deutschland
thanks guys, but I was able to work it out....and I am using strio.c...lol
Thank you.


Everybody Poops.
here are some tutorials I made.
http://www.acknexturk.com/blender/

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1