Page 1 of 1
Obtaining values from a table
Posted: Tue Feb 15, 2011 4:30 pm
by pecaN
Hi, I¨ve quite a silly problem. I want to find out bitmap font's sizes but
GetAvailableFonts() returns something like "Table: 0x25F136" or so... and the same goes for the
TextExtent() command...please how can i get values from this? I have never come across this so far...thanx pecaN
Re: Obtaining values from a table
Posted: Tue Feb 15, 2011 5:18 pm
by Allanon
I pecaN,
generally you can obtain values from a table depending on the table index, for example if you have a table indexed by numeric values:
Code: Select all
Local mytable = { "alpha", "beta", "gamma" }
(*Note)
You can obtain the first item with:
the secondo item with
and so on...
You can also have tables indexed by strings, for example:
Code: Select all
Local mytable = { item1 = "alpha", itembeta = "beta", gamma = "gamma" }
This time you can obtain values with:
or even better
Code: Select all
Print(mytable.item1)
Print(mytable.itembeta)
Print(mytable.gamma)
For your specific question you have to look at the documentation of GetAvailableFonts() and see what fields it returns, so you can do something like:
Code: Select all
Local af = GetAvailableFonts()
Print(af.returned_field)
I don't have near me the Hollywood doc so I have used
returned_field as a placeholder for the real field returned by this function
(*Note)
note that you can write the table assignment with:
Code: Select all
Local mytable = { [0] = "alpha", [1] = "beta", [2] = "gamma" }
too
Re: Obtaining values from a table
Posted: Thu Feb 17, 2011 6:29 pm
by pecaN
Hi Allanon,
txanx very much for your exhaustive reply (as always!), it helped me solve my problem !!! Regards pecaN
Re: Obtaining values from a table
Posted: Fri Feb 18, 2011 9:24 am
by Allanon
Great!
