Obtaining values from a table

Discuss any general programming issues here
Post Reply
pecaN
Posts: 124
Joined: Thu Jun 10, 2010 4:15 pm

Obtaining values from a table

Post 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
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Obtaining values from a table

Post 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:

Code: Select all

Print(mytable[0])
the secondo item with

Code: Select all

Print(mytable[1])
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:

Code: Select all

Print(mytable["item1"])
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
pecaN
Posts: 124
Joined: Thu Jun 10, 2010 4:15 pm

Re: Obtaining values from a table

Post by pecaN »

Hi Allanon,
txanx very much for your exhaustive reply (as always!), it helped me solve my problem !!! Regards pecaN
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Obtaining values from a table

Post by Allanon »

Great! :D
Post Reply