Pages: [1]   Go Down
  Print  
Author Topic: text file routines  (Read 781 times)
0 Members and 1 Guest are viewing this topic.
hiker_jon
Full Member
***
Offline Offline

Posts: 154


« on: 13 / August / 2008, 17:54:33 »

Hi,
I would like to read and parse a text file.  I notice that some basic routines (like fgets) are missing from the c library.  Am I right?  Should I write them myself? or has someone already done this.

What I want to do is read lines from a text file then do some simple parsing of the lines.

Thanks,
Jon
Logged
ewavr
Developers
Hero Member
****
Offline Offline

Posts: 1053

A710IS


« Reply #1 on: 13 / August / 2008, 18:24:39 »

-deleted-
« Last Edit: 13 / August / 2008, 21:05:11 by ewavr » Logged
zeno
Sr. Member
****
Offline Offline

Posts: 302


« Reply #2 on: 13 / August / 2008, 18:42:02 »

I must be missing something - don't the script handling routines do something close to what you want? See script_load in core/script.c (and lib/ubasic/ubasic.c) for example.
Logged
reyalp
Guru Member
******
Offline Offline

Posts: 2706


« Reply #3 on: 13 / August / 2008, 21:00:00 »

Might be overkill, but you could also use lua for this

Say your text file has a bunch of
name=value
statements
create a lua state
lua_dofile your text file
getglobal on each name you are interested in.
delete you lua state.

there's a bunch of other ways you could do it too, but that's probably the most straightforward.
Logged

Don't forget what the H stands for.
Pages: [1]   Go Up
  Print  
 
Jump to: