Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Icon > Generator "Clea...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 132 of 181
Post > Topic >>

Generator "Cleanup" Question

by Cp200205@[EMAIL PROTECTED] Nov 26, 2006 at 08:22 AM

I am curious how to deal with generators when called expecting just one
result. Take this for example:

procedure genme(n)
	local a

	write("genme")

	every a := 1 to n do
		suspend a

	write("/genme")
end

procedure main()
	local a

	a := genme(5)
	write(a)

	every a := genme(3) do
		write(a)
end

That prints:

genme
1
genme
1
2
3
/genme

Notice on the first, /genme was not called. In this example, no big
deal, but what about:

procedure dbi_conn_find(dbi_conn, sql)
	local res, row
	res := dbi_conn_query(dbi_conn, sql)
	every row := dbi_result_fetch_next_table(res) do {
		suspend row
	}
	dbi_result_free(res)
end

The result *must* be freed. So, with the above procedure, the following
works just fine:

every row := dbi_conn_find(conn, "SELECT * FROM people WHERE name =
'JOHN'") do
    write_person(row)

However:

first := dbi_conn_find(conn, "SELECT * FROM people WHERE name =
'JOHN'")

will fail to call "dbi_result_free".

Any thoughts on how to handle this?

Thanks,

Jeremy




 6 Posts in Topic:
Generator "Cleanup" Question
Cp200205@[EMAIL PROTECTED  2006-11-26 08:22:20 
Re: Generator "Cleanup" Question
gmt@[EMAIL PROTECTED] (G  2006-11-27 19:40:23 
Re: Generator "Cleanup" Question
espie@[EMAIL PROTECTED]   2006-11-27 20:45:30 
Re: Generator "Cleanup" Question
Steve Wampler <swample  2006-11-27 14:12:14 
Re: Generator "Cleanup" Question
Cp200205@[EMAIL PROTECTED  2006-11-27 14:15:29 
Re: Generator "Cleanup" Question
Steve Wampler <swample  2006-11-27 16:22:42 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue May 13 23:17:55 CDT 2008.