lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tuesday, March 20, 2001, at 06:02 PM, Honglei Tu wrote:
> function gettable(t) 
> 	local numEntries, e, name, flag, value 
> 	numEntries = GetNumEntriesForTable(t) 
> 	print("number of entries is ", numEntries) 
> 	for i=1, numEntries do 
> 		e = GetTableEntryByIndex(b, i) 
> 		name = GetEntryName(e)  
> 		flag = GetEntryFlag(e) 
> 		value = GetEntryValue(e) 
> 		print("name is ", name) 
> 		print("flag is ", flag) 
> 		print("value is ", value) 
> 		if (flag == 32) 
> 		then 
> 			gettable(value) 
> 		end		 
> 	end 
> end 
>  
> But I failed to recursively call gettable in gettable. 
> Anyone can tell me how to call lua functions recursively ? 


That should work just fine.

Here's a simple example that you can verify:

function test(n)
  if n > 10 then return end
  print(n)
  n = n + 1
  test(n)
end

test(1)


Steve