Thread Tools Display Modes
12-27-07, 05:49 PM   #1
LucifersHand
A Murloc Raider
 
LucifersHand's Avatar
Join Date: Dec 2007
Posts: 5
Question Maximum length of a String variable and FontString?

I am working on a project that will show a list of your professions supplies. I know that there have been mods like this made in the past but I don’t really like them that much and I figured what the hell. I knowlage in VB and C+ and figured I would give it a try.


My question is, what is the maximum length that LUA can handle with a string variable and what is the maximum length that a <FontString> can display?

For example in my .lua I have something like this for creating my list. It pulls the items out of a table

Code:
str1 = “”;
i = 1;
x = table.getn(strTable) ; -- total length of the table
while (i <= x) do
	str1 = str1 .. strTable[i] .. “\n”;
	i = i + 1;
end
When I set str1 to a <FontString> in the XML it does list the items in strTable line by line but it only makes it to line 14 no matter if the table has more then 14 variables.

Is there another way of doing this with LUA? (I am still trying to learn everything it can do and how it does it) or can anyone tell me if I might be hitting the maximum length of a string variable or the <FontString> in XML? If this is the case then I can easily change my code to adapt to its capabilities.

I am breaking up the supplies into groups like ore, bars, ... but some of the groups will still be large is size.

thanks
  Reply With Quote
12-27-07, 06:48 PM   #2
Layrajha
A Frostmaul Preserver
 
Layrajha's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 275
You'd have a hard time reaching the maximum length of the strings allowed by wow's lua interpretor, so I doubt it could be the problem. However, getn() behaves a bit strangely, you should read about it on lua.org's manual.

Also, the best way to iterate in a table is often to use the "for" constructor, with this kind of syntax:

Code:
for key,value in pairs(mytable) do
  Something(key, value)
end
If you don't care about the keys but only about the values stored, you can do:

Code:
for value in mytable do
  Something(value)
end
The problem is that if your table looks like...
Code:
{
  [1] = "a",
  [2] = "b",
  [3] = "c",
  [4] = "d",
}
... then the output of a concatenation run via "for ... in ... do" will most likely be something like "badc" instead of "abcd". If the order of the keys is important (if you want to concatenate 1, then 2, then 3, then 4), then you can check this wowwiki tutorial.

I hope this helps a bit.
  Reply With Quote
01-01-08, 10:20 AM   #3
LucifersHand
A Murloc Raider
 
LucifersHand's Avatar
Join Date: Dec 2007
Posts: 5
Thanks for the reply. Im still learning how lua works and the best way to do things in it.

ill give it a try with the for loop.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Maximum length of a String variable and FontString?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off