Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,388 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Read seperate strings/vars from file #304628
01/09/10 13:13
01/09/10 13:13
Joined: Jul 2009
Posts: 96
M
mEnTaL Offline OP
Junior Member
mEnTaL  Offline OP
Junior Member
M

Joined: Jul 2009
Posts: 96
Hi. How can I make file_str_read to read strings from a file seperated by comma ","

for example:
I have a text file which consist of: This, is, a, text
How can I read the THIRD string only ??

Re: Read seperate strings/vars from file [Re: mEnTaL] #304631
01/09/10 13:26
01/09/10 13:26
Joined: Sep 2009
Posts: 1,032
Budapest
Aku_Aku Offline
Serious User
Aku_Aku  Offline
Serious User

Joined: Sep 2009
Posts: 1,032
Budapest
Whith three successive file_str_read you will get the string "a".
Whith the fourth you got the "text". Although i didnt find this information in the manual, my experiencies show that.
Maybe i am wrong, i am sure there is more experted users here, who will point out what is the truth.

Re: Read seperate strings/vars from file [Re: Aku_Aku] #304655
01/09/10 17:39
01/09/10 17:39
Joined: Jul 2009
Posts: 96
M
mEnTaL Offline OP
Junior Member
mEnTaL  Offline OP
Junior Member
M

Joined: Jul 2009
Posts: 96
Hmm I'm not sure I understood that very good : (

Comeon does anyone know the easy way? There must be a way to read comma seperated strings from a file!

Re: Read seperate strings/vars from file [Re: mEnTaL] #304717
01/10/10 11:30
01/10/10 11:30
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline
Expert
Helghast  Offline
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
open the file for reading, and perform 3 file_str_read's as aku_aku said... then close the file, the result should be "a".
This already is the easy way wink

you could make a function for this though...
Here's something i made really fast.

Code:
#include <acknex.h> // include for Pure Mode
#include <default.c> // default key functions

STRING* fileContainer = ""; // empty string for displaying

// the function that return a specific string from the file
function getCertainString(fhandle, stringAmount) {
	var i;
	STRING* tempStr = str_create("");
	
	// search for string
	for(i=0; i<stringAmount; i++) {
		file_str_read(fhandle, tempStr);
	}
	
	return tempStr; // return the string
}

function main() {
	var filehandle = file_open_read("testFile.txt"); // filehandle to the file
	
	// function returns a string, so make sure to store it in one
	// you can change the string you wanna get with the 2nd parameter
	fileContainer = getCertainString(filehandle, 3);
	
	// display the string that contains the text from the file
	while(1) {
		draw_text(fileContainer, 10, 10, vector(255,255,255));
		
		wait(1);
	}
}



Hope this helps laugh
regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: Read seperate strings/vars from file [Re: Helghast] #304798
01/10/10 21:52
01/10/10 21:52
Joined: Jul 2009
Posts: 96
M
mEnTaL Offline OP
Junior Member
mEnTaL  Offline OP
Junior Member
M

Joined: Jul 2009
Posts: 96
Yes it works. It seems that is the only way to read different strings from a file. Contiec should write that in the manual. Anyway.. Thx Aku_Aku and Helghast


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | 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