Monday, November 08, 2010 at 12:01 AM.


on query (domain, expression, adrlist, adrerrorstring=nil) {
		<<1/12/08; 10:14:09 AM by DW
	local (nexttoken = nil);
	adrlist^ = {};
	loop {
		local (t, xstruct);
		new (tabletype, @t);
		t.DomainName = domain;
		t.MaxNumberOfItems = 250;
		t.QueryExpression = expression;
		if nexttoken != nil {
			t.NextToken = nexttoken};
		if not s3.simpleDb.httpClient ("Query", @t, adrerrorstring, @xstruct) { //error
			return (false)};
		<<scratchpad.xstruct = xstruct
		nexttoken = nil;
		local (adrresponse = xml.getaddress (@xstruct, "QueryResponse"));
		local (adrresult = xml.getaddress (adrresponse, "QueryResult"), adr);
		for adr in adrresult {
			if nameof (adr^) endswith "ItemName" {
				adrlist^ = adrlist^ + adr^}
			else {
				if nameof (adr^) endswith "NextToken" {
					nexttoken = adr^}}};
		if nexttoken == nil { //hit the end of the list
			return (true)}}};
bundle { //test code
	local (es);
	if query ("flickrFanData", "['flickrUserName' = 'scriptingnews']", @scratchpad.querylist, @es) {
		edit (@scratchpad.querylist)}
	else {
		dialog.alert (es)}}

This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.