text file routines - General Discussion and Assistance - CHDK Forum

text file routines

  • 3 Replies
  • 2413 Views
text file routines
« on: 13 / August / 2008, 12:54:33 »
Advertisements
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

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: text file routines
« Reply #1 on: 13 / August / 2008, 13:24:39 »
-deleted-
« Last Edit: 13 / August / 2008, 16:05:11 by ewavr »

*

Offline zeno

  • *****
  • 889
Re: text file routines
« Reply #2 on: 13 / August / 2008, 13: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.
A570, S100, Ixus 127
Author of ASSIST, STICK, WASP, ACID, SDMInst, LICKS, WICKS, MacBoot, UBDB, CFGEdit

*

Offline reyalp

  • ******
  • 13456
Re: text file routines
« Reply #3 on: 13 / August / 2008, 16: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.
Don't forget what the H stands for.


 

Related Topics