Page 1 of 1

Arrays

Posted: Mon Feb 13, 2006 11:35 am
by Halikar
I'm not sure if this qualifies as a bug, if it's just strangeness, or if I'm missing something important. When building arrays of gump statements (and I'm fairly sure our shard is running the latest version of POL 096), I've encountered some issues that prevent the built gumps from displaying properly depending on how the array is assembled. Here is an example:

Code: Select all

use uo;

program textcmd_test (me, text)
	var aGumpPiece1 := array;
	var aGumpPiece2 := array;
	var aGumpPiece3 := array;
	var aGumpLayout1 := array;
	var aGumpLayout2 := array;
	var aGumpLayout3 := array;
	var aGumpData := array;
	var iGumpChoice := 0;
	
	aGumpPiece1 := {
		"page 0",
		"resizepic 50 50 2620 150 150"
	};
	
	aGumpPiece2 := {
		"gumppic 60 60 14",
		"gumppic 60 90 16"
	};
	
	aGumpPiece3:= {
		"gumppic 60 120 18"
	};

	// Method 1
	aGumpLayout1 := aGumpPiece1;
	aGumpLayout1.append (aGumpPiece2);
	aGumpLayout1.append (aGumpPiece3);
	SendSysMessage(me, "Gump1: " + aGumpLayout1);
	iGumpChoice := SendDialogGump (me, aGumpLayout1, aGumpData);
	
	//Method 2
	aGumpLayout2 := aGumpPiece1 + aGumpPiece2 + aGumpPiece3;
	SendSysMessage(me, "Gump2: " + aGumpLayout2);
	iGumpChoice := SendDialogGump (me, aGumpLayout2, aGumpData);

	//Method 3
	aGumpLayout3 := aGumpPiece1;
	foreach item in aGumpPiece2;
		aGumpLayout3[len(aGumpLayout3 + 1)] := item;
	endforeach
	aGumpLayout3[len(aGumpLayout3 + 1)] := aGumpPiece3;
	SendSysMessage(me, "Gump3: " + aGumpLayout3);
	iGumpChoice := SendDialogGump (me, aGumpLayout3, aGumpData);

endprogram
Each method seems to generate extra characters that prevent parts of the gump from displaying, but I can't pin down why with any consistancy, except for the append method. With appends, I always get extra characters.

Anyone have any thoughts?

Posted: Mon Feb 13, 2006 11:09 pm
by MuadDib
You are appending arrays into arrays, etc. Append only strings into the arrays (no need for the {} brackets around your stuff if you appending it into an array). That is one thing.

Posted: Tue Feb 14, 2006 4:07 pm
by Halikar
Yup, that would certainly explain some of it, and may give me enough to figure out why I'm getting inconsistant results in pinning down my errors. Part of it is I'm trying to make arrays that are larger than single dimensional, and in one case an array of structs. Not easy sometimes keeping track of which plane I'm working with. :)