Note: This is an archived post that was originally sent to the Hollywood mailing list on 10 Apr 2007 19:47:56 +1000
Hello Andreas,
This still fails the test.
Here is the function so you can understand why I have both conditions being checked.
Code: Select all
Function p_ParseFile (file$, tag)
Local ret={}
Local linetype=0
Local value$=""
While (linetype<>3) Or ((linetype<>3) And (tag<>1))
While (linetype <> 3)
ret=p_ParseLine (TrimStr (ReadLine (file$), " ", False), linetype, tag)
linetype=ret[0]
Switch linetype
Case 1:
Case 2:
linetype=0
Case 3:
p_DebugPrint (ret[2], tag, True, True)
Case 4:
/* p_DebugPrint (ret[2], tag, True, True) */
tags[tag]=ret[2]
p_ParseFile (file$, (tag+1))
linetype=0
Case 5:
p_DebugPrint (ret[2], tag, False, True)
p_AddTableEntry (ret[2], tag)
linetype=0
Case 6:
value$=ret[2]
/* p_DebugPrint (ret[2], tag, False, True) */
Case 7:
value$=value$ .. " " .. ret[2]
/* p_DebugPrint (ret[2], tag, False, True) */
linetype=6
Case 8:
value$=value$ .. " " .. ret[2]
value$=p_SplitLine (value$, tag)
p_DebugPrint (value$, tag, False, True)
p_AddTableEntry (value$, tag)
linetype=0
EndSwitch
Wend
Wend
EndFunction
The file that is being read has the following tags that get checked..
Code: Select all
<resources>
<colors>
<no-color a="0" r="0" g="0" b="0" />
<white a="255" r="255" g="255" b="255" />
</colors>
</resources>
With the function calling itself I found that it was neccessary to add an extra closing tag to the end of the file to avoid the end of file so I added </> to the end..
It seems that the While loop does work but it is not existing soon enough to the original iteration of the function..
Oh well.. for the time being I will have to modify the files..
I also seem to have difficulty printing [ brackets which appear in the config files I am reading.. but have no problem with " even though I don't use \ to format the output for the double quote.. This is only a concern when debugging the output and when I have completed testing I will re-use [ unless there are problems with adding this to a table even though they are in a string i.e.
Code: Select all
table["resources.fonts.main-font"]["shadow"]="[no-color]"
Would this be the best way to store these values.. I have been trying various ways of building tables and this appeared to be the best way to go.. I got lots of errors doing it other ways.. I originally attempted to use the examples and build the table but couldn't work out how to add to the table after an initialising..
ideally I would have liked to do this table {resources {colors {no-color {default=,$00000000, argb=$00000000, rgb=$000000}}}}
and add to the table other resources.. table {resources {fonts {main-font {shadow="[no-color]", size="18", type-face="Arial"}}}}
And then access them via SetFontColor (table.resources.colors.no-color.rgb)
But this doesn't seem to fit with how I thought the tables could be manipulated, but I am no expert..
I ended up butchering them and access them via
Code: Select all
SetFontColor (table["resrouces.colors.no-color"]["rgb"])
Not exactly ideal.. expecially when you need to know exactly where the table entries are since they are only referenced in the config files by no-color.. I get around this by having a second table called index which you can pass it the unique tag or identifier i.e. no-color and it would return the table entry.. i.e.
Code: Select all
SetFontColor (table [index["no-color"]]["rgb"])
Anyway this is becoming a long and probably tedious e-mail for you all.. but I am very interested in better ways of managing multi dimension tables..
Regards,
Dwayne