Re: Parsing question...

new topic     » goto parent     » topic index » view thread      » older message » newer message

On 26 Aug 2000, at 21:07, LEVIATHAN wrote:

> >  Can you give a short example?
> >
>
> Heh, I knew I was probly gonna havta do that :)
>
> example:
> health          25      5       14      14      0.0     1.0     0.0     0.75
> healthbar       285     239     value   2       1.0     0.0     0.0     1.0
> gfx/2d/colorbar.tga 0.2                     0

You could look at strtok.e with a readme which i just sent to RDS for the
archives. You
can use it to find/replace/delete tokens in a sequence/string.

I don't know per your example how the users are separated in the data file, or
if each
user has their own file, and i can't see a tab char. Assuming each user has
their own
file, and each line is terminated by a ascii 10, then after reading the file
into filedata,

sequence healthline = gettok(filedata,1,10)
sequence healthbarline = gettok(filedata,2,10)
object healthline_valnum4 = gettok(healthline,4,TheAsciiForTab) = 14

If you put all the datum for all the users into one file, and read it as one
sequence, and
each user has an xml tag, such as <LEVIATHAN> , and you xml'd the rest of the
data
as well, then you could use getxml() to parse the data, altho i don't have a
putxml()
yet, since i didn't need one, sorry. So getxml(filedata,"LEVIATHAN","/",1) would
return
your data, and getxml(filedata,"Kat","/",0) would return {} since i don't have a
data in
your file.

<LEVIATHAN>
<health>25,5,14,14,0.0,1.0,0.0,0.75</health>
<healthbar>285,239,value,2,1.0,0.0,0.0,1.0,gfx/2d/colorbar.tga 0.2,0<healthbar>
</LEVIATHAN>
(I used commas just so i'd have something to see there.)

Then,
yourhealth = getxml(yourdata,"health","/",1")

{25,5,14,14,0.0,1.0,0.0,0.75}

Or, if you parse(yourhealth,',') , it would be:

{"25","5","14","14","0.0","1.0","0.0","0.75"}

so you could do:

energy = 5
sight = 8
seq yourhealthseq[energy] and get the "0.0"
seq yourhealthseq[sight] and get the "0.75"

Which is a fine scheme to avoid the error of getting "gfx/2d/colorbar.tga" into
an
integer, `course, there are other schemes.

Kat

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu