Loading a Select List into a variable efficiently (OpenInsight 32-Bit)
At 19 MAR 2009 12:41:48PM Jim Peters wrote:
I am sure this has been analyzed in depth before… What is the most efficient way of getting a select list into a variable? Is there a better way than looping through a series of readnext's and building the list one key at a time?
At 19 MAR 2009 01:26PM Bob Carten wrote:
I always loop through.
However, based on a tip from Carl @ Sprezz, I presize a buffer and drop the ids into it. Apparently that is the fastest way to load a string, appending ( list:= val:@fm ) is next fastest, then list=val, slowest is list=val. Example: function UnMake.List(inDelim) /* Opposite of Make.list Capture active.select in a variable */ $Insert Logical delim=if assigned(delim) then delim1,1 else @fm if delim=' then delim=@fm avg_keysize=20 list=space(@reccount*avg_keysize) eof=false$ pos=1 loop readnext id else eof=true$ until eof ilen=len(id) + 1 listpos,ilen=id:delim pos += ilen repeat list=if pos ] 1 then list0,pos-2 else
return list </QUOTE> —- === At 19 MAR 2009 01:39PM Mike Ruane wrote: === <QUOTE>How about the SELECT..INTO that's in 9.0? Mike </QUOTE> —- === At 19 MAR 2009 02:16PM Jim Peters wrote: === <QUOTE>Ahh! Something new is always welcome! I suspect the fastest is BTREE.EXTRACT when it suits one's situation. Bob, that was the information I had remembered seeing or hearing someplace that I could not locate. Thanks! </QUOTE> —- === At 21 MAR 2009 08:19PM Don Muskopf wrote: === <QUOTE>Mike, is the SELECT..INTO statement documented? If so, I can't seem to find it in the Help file. Thanks. </QUOTE> —- === At 23 MAR 2009 08:39AM Sean FitzSimons wrote: === <QUOTE>Don, Select_Into will be released with 9.0.1. It will provide methods for returning List statements into various output formats, such as CSV, HTML, straight text, tab delimited and Edit Table Arrays. Sean </QUOTE> —- === At 23 MAR 2009 09:36AM Don Muskopf wrote: === <QUOTE>Thanks Shawn. That sounds like a great feature. Looking forward to it. Don </QUOTE> —- === At 23 MAR 2009 09:40AM Don Muskopf wrote: === <QUOTE>Sean, sorry about the spelling. I don't know what I was thinking. I should have had my morning coffee first, lol. </QUOTE> —- === At 23 MAR 2009 04:34PM Matthew Crozier wrote: === <QUOTE>How about XML ?? Cheers, M@ [img]http://www.vernonsystems.com/images/logo_main_ani.gif[/img] </QUOTE> —- === At 23 MAR 2009 06:24PM Mike Ruane wrote: === <QUOTE>Why use XML when you can use JSON? Mike </QUOTE> —- === At 24 MAR 2009 12:31AM Matthew Crozier wrote: === <QUOTE>Why use XML when you can use JSON? 'Cause what I need is XML
,'New',. Could use INET_OI_XML(), I guess - but a SELECT_INTO with XML output would seem a lot cleaner. Does OI 9.0 support JSON like it does for XML? Cheers, M@ [img]http://www.vernonsystems.com/images/logo_main_ani.gif[/img] </QUOTE> —- === At 24 MAR 2009 02:02PM Bob Carten wrote: === <QUOTE> Matt OI 9.01 will have JSON support You can use code like the example below. We expect to build a select into JSON atop that. We hope I'll to deliver Select Into XML and Select Into ADO as well. Not sure that'll make 9.01 <code> declare function RTI_JSON myObj=rti_json(
) list=Get_Property(@window:'.GRID', 'LIST') cnt=count(list, @fm) + ( list #
) k=0 for i=1 to cnt item=list val=list if item #then obj=rti_json(
,'New', item, val) x=rti_json(myObj, 'SetValue',:k:
, obj, 1) k+=1 end next JString=rti_json(myObj, "Stringify") </code> </QUOTE> —- === At 24 MAR 2009 04:44PM Matthew Crozier wrote: === <QUOTE>Nice! Sounds like that is going to open a whole lot of doors :). BTW, just figured out that some of that code isn't displaying correctly… <code> for [/color]i=[/color]1 [/color]to [/color]cnt item=list1] [/color]val=list2][/color][/color][/size] </code> Cheers, M@ [img]http://www.vernonsystems.com/images/logo_main_ani.gif[/img] </QUOTE> View this thread on the Works forum...