• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[Solved] Textmacro issue

Status
Not open for further replies.

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
Hello.

I figured textmacros would be really handy to create dynamic lists/arrays.
I made a few simple functions to make the list itself work and then I wanted to add the textmacro stuff afterwards.

But I get "IntegerList is not a type that allows .syntax" error when I try to compile the code.
IntegerList list = IntegerList.create();//line that gives the error

JASS:
//! zinc
	library TextMacroList
	{
		//! textmacro LIST takes NAME, TYPE
			struct $NAME$List
			{
				$TYPE$ intList[999];
				integer index = 0;
				static method create() -> thistype
				{
					thistype this = thistype.allocate();
					return this;
				}
				
				method Add($TYPE$ value)
				{
					intList[index] = value;
					index += 1;
				}
				
				method RemoveAt(integer i)
				{
					intList[i] = intList[index - 1];
					index -= 1;
				}
			}
		//! endtextmacro
		//! runtextmacro LIST("Integer","integer")
	}
	 
	library demo requires TextMacroList
	{
		function onInit()
		{
			IntegerList list = IntegerList.create();
			list.Add(1);
			list.Add(2);
			list.Add(3);
			list.Add(4);
			BJDebugMsg(I2S(list.intList[1]));
			list.RemoveAt(1);
			BJDebugMsg(I2S(list.intList[1]));
		}
	}
//! endzinc

Yes, I know that there are flaws in the code. That's not the issue though.

edit: I moved the //! runtextmacro LIST("Integer","integer") elsewhere but then I get "unexpected struct" instead.

edit2: Actually I get different errors every time I move it actually.
 
Status
Not open for further replies.
Top