Question about variable scope inside function

I’ve written the following code to load quote data to a partitionedtable (follow the example from kdb+ for mortals):ldchunk:{.Q.en[:/db;] select code,id,time,datatype,val from flipcodeiddtimedatatypeval!("IIDTSF";6 10 9 10 3 16) 0: x wheredatatype within CACB}ldata1:{[fn] d:"D"$ssr[fn;":/HKSE/BidAsk/ba_mb_";""]; / d is the date parsedfrom the filename h1: sv :db,($string d),quote1; /h1 is the file handler of thepartition of that date .Q.fs[{0N!.[h1;();,;ldchunk x]}] $fn}however, I got a error:{0N!.[h1;();,;ldchunk x]}'h1it seems in .Q.fs[{…}] function call, it cannot recognize ldata1’slocal variable in the embedded function definition.In this case, could anyone tell me how to make this piece of codework?Thanks!

 .Q.fs[{0N!.[x;();,;ldchunk y]}h1] `$fn

Thanks! It works for my case.On Feb 14, 4:06?pm, Charles Skelton <char…> wrote:> ?.Q.fs[{0N!.[x;();,;ldchunk y]}h1] $fn&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; On Mon, Feb 14, 2011 at 8:24 AM, bovine <chenying...> wrote:&gt; &gt; I've written the following code to load quote data to a partitioned&gt; &gt; table (follow the example from kdb+ for mortals):&gt;&gt; &gt; ldchunk:{.Q.en[:/db;] select code,id,time,datatype,val from flip> > codeiddtimedatatypeval!(“IIDTSF”;6 10 9 10 3 16) 0: x where> > datatype within CACB}>> > ldata1:{[fn]> > ?d:“D”$ssr[fn;“:/HKSE/BidAsk/ba_mb_”;“”]; ?/ d is the date parsed> > from the filename> > ?h1:sv:db,($string d),quote1; ?/h1 is the file handler of the> > partition of that date> > ?.Q.fs[{0N!.[h1;();,;ldchunk x]}] `$fn> > }>> > however, I got a error:> > {0N!.[h1;();,;ldchunk x]}> > 'h1>> > it seems in .Q.fs[{…}] function call, it cannot recognize ldata1’s> > local variable in the embedded function definition.>> > In this case, could anyone tell me how to make this piece of code> > work?>> > Thanks!>> > –> >

Submitted via Google Groups</chenying…></char…>