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
4 registered members (TipmyPip, AndrewAMD, dBc, clonman), 18,621 guests, and 5 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
Problem with reading txt-files #352083
12/31/10 12:25
12/31/10 12:25
Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Roxas Offline OP
Member
Roxas  Offline OP
Member

Joined: Apr 2008
Posts: 144
Germany | Niedersachsen (Lower...
Hey guys

I want to make a txt-file-based database as an item database for my project.

the database looks like this

Code:
1,Potion,8,0,0,0,4,0,0,2,0,0,0,2,40,
2,Remedy,8,0,0,0,4,0,0,2,0,0,0,2,60,
...



and so on.

The Problem is, that I'm not able to determine in which line the text cursor might be, and I'm also not able to place the cursor to a specific line. I tried a lot of things with file_seek, file_find and file_str_read but it doesn't work at all.

is there a way to specify the line in which the cursor in the txt file is or does anyone have a good solution for achieving this?

thanks in advance
Roxas

Last edited by Roxas; 12/31/10 12:26.
Re: Problem with reading txt-files [Re: Roxas] #352112
12/31/10 23:18
12/31/10 23:18
Joined: Dec 2008
Posts: 271
Saturnus Offline
Member
Saturnus  Offline
Member

Joined: Dec 2008
Posts: 271
Just count the number of newline characters ('\n') until the current read/write position.

Something like this (pseudocode):
Code:
int number_of_lines = 1;
for (i = 0; i < file_position; i++) {
    if (file_chars[i] == '\n') {
        number_of_lines++;
    }
}




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