Table field 1 not initialized

Find quick help here to get you started with Hollywood
Post Reply
amyren
Posts: 361
Joined: Thu May 02, 2019 11:53 am

Table field 1 not initialized

Post by amyren »

Am I doing something wrong here or could this be a bug?

This code will quit with the following error:
Error in line 8 (Unnamed4.hws): Table field 2 was not initialized!

To reproduce, select and ban first user on the list, then do the same for the second user. Then select first user again and remove ban.

Code: Select all

bannedlist$ = {}
playerlist$ = {"Tom", "Peter", "Adrian"}
Repeat
If (ListItems(playerlist$) = 0) Then r = -1 Else r = ListRequest("Playerlist", "BAN player", playerlist$)
	receivername$ = playerlist$[r]	
	alreadybanned = False
	For i = 0 To ListItems(bannedlist$) -1
		If receivername$ = bannedlist$[i]
			alreadybanned = True
			sel = SystemRequest("Banned user", receivername$.." is already banned\nDo you want to remove the ban?", "Remove|Cancel")
			Switch sel
			Case 1:
				RemoveItem(bannedlist$, i)
			EndSwitch
		EndIf
	Next
	If alreadybanned = False
		InsertItem(bannedlist$, receivername$); add user to bannedlist
	EndIf
VWait()
Forever
amyren
Posts: 361
Joined: Thu May 02, 2019 11:53 am

Re: Table field 1 not initialized

Post by amyren »

Ok, sleeping on it helped:)
I see know why this error comes.
I am removing the table item while still in the FOR NEXT loop, so the next loop will throw the error.
Post Reply