Obtaining values from a table

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

Obtaining values from a table

Post by pecaN » Tue Feb 15, 2011 4:30 pm

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: 461
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Obtaining values from a table

Post by Allanon » Tue Feb 15, 2011 5:18 pm

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
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

pecaN
Posts: 101
Joined: Thu Jun 10, 2010 4:15 pm

Re: Obtaining values from a table

Post by pecaN » Thu Feb 17, 2011 6:29 pm

Hi Allanon,
txanx very much for your exhaustive reply (as always!), it helped me solve my problem !!! Regards pecaN

User avatar
Allanon
Posts: 461
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: Obtaining values from a table

Post by Allanon » Fri Feb 18, 2011 9:24 am

Great! :D
----------------------------
[Allanon] Fabio Falcucci
AMC - Creative Development // Docs Site // Support Forum
Support me on Patreon for Hollywood libraries!

Post Reply