Could use another set of eyes for this

Help section from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

renagade8
orc pawn
orc pawn
Posts: 28
Joined: Sat Oct 19, 2002 9:17 pm

Could use another set of eyes for this

Post by renagade8 » Mon Sep 22, 2003 6:32 pm

The following code is part of a larger macro but this part of the code checks to see if a target id is already in the array and if it is not then it stores the new id in the next slot of the array. Although, i think the problem spot is the bold portion, it seems to ignore this check even though it is true (i check this with /echo), so it continues to add the same target id to the array.

If anyone could help me figure out a way that this would work or possibly another way around this, it would be greatly appreciated. hopefully another pair of eyes could see if i made a small mistake or not.

Code: Select all

Sub chktarg
	/varset l0 0
	/for l0 0 to $arraysize
		[b]/if n $target(id)==a(0,$l0) {[/b]
			/call chkdbuff $l0
			/return
		}
	/next l0
	/call addtarg $calc($l0-1)
/return

Sub addtarg
	/varset a(0,$p0) $target(id)
	/varset a(1,$p0) 0
	/varset a(2,$p0) 0
	/varadd arraysize 1
/return
-ren

MacroFiend
a grimling bloodguard
a grimling bloodguard
Posts: 662
Joined: Mon Jul 28, 2003 2:47 am

Post by MacroFiend » Mon Sep 22, 2003 6:53 pm

I haven't worked with arrays too much yet, so I could be wrong but don't you need a $ before the a(0,$l0) in your bolded line?

renagade8
orc pawn
orc pawn
Posts: 28
Joined: Sat Oct 19, 2002 9:17 pm

Post by renagade8 » Mon Sep 22, 2003 9:34 pm

man do i feel stupid, thanks i knew i needed another person to look it over.

-ren

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Mon Sep 22, 2003 10:51 pm

Does

Code: Select all

/if n $target(id)==a(0,$l0) {
need to be

Code: Select all

/if n $target(id)==$a(0,$l0) {
I haven't ever used arrays so this is a guess on my part.