Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,135 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 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 | 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