From: Jean-Christian I. <jc....@gm...> - 2015-04-23 09:47:02
|
Thank you very much. I never would have thought to use list :) Jean-Christian On Thu, Apr 23, 2015 at 4:35 PM, Stephan Houben <ste...@gm...> wrote: > Hi Jean-Christian, > > This should work: > > lsort -command [list custom_sort $fileId $attrNames] $records > > Unlike the {...} construct, [list ...] does not inhibit variable expansion > in the ... part. > > Stephan > > > 2015-04-23 2:39 GMT+02:00 Jean-Christian Imbeault <jc....@gm...>: > >> I'm new to Tcl and trying to port some legacy Tcl 8.0 (I know!) code to >> 8.5. >> >> The legacy behaviour of lsort -command is different in 8.0 than 8.5 and I >> would like some help in figuring out how to port a line of legacy code to >> 8.5. >> >> Basically 8.0 would allow passing in more than two arguments to the sort >> command using braces and 8.0 would do substitution of any variables inside >> the braces. 8.5 does not interpolate the variables in the braces. >> >> Unfortunately I am too new to Tcl and don't quite have a handle on >> interpolation and how to get the same behaviour in 8.5 >> >> How can I pass in extra arguments to a custom sorting command? >> >> == Old 8.0 behaviour == >> >> % set fileId FILENAME >> FILENAME >> % set attrNames [list att1 att2] >> att1 att2 >> % set arg1 { {1} {stuff} } >> {1} {stuff} >> % set arg2 { {2} {more stuff} } >> {2} {more stuff} >> % lappend records $arg1 >> { {1} {stuff} } >> % lappend records $arg2 >> { {1} {stuff} } { {2} {more stuff} } >> % proc custom_sort {a1 a2 toSort1 toSort2} { >> puts "a1: $a1" >> puts "a2: $a2" >> puts "toSort1; $toSort1" >> puts "toSort2: $toSort2" >> return 1 >> } >> % lsort -command {custom_sort $fileId $attrNames} $records >> a1: FILENAME >> a2: att1 att2 >> toSort1; {1} {stuff} >> toSort2: {2} {more stuff} >> { {2} {more stuff} } { {1} {stuff} } >> % >> >> == 8.5 Behaviour == >> >> [only showing output] >> >> % lsort -command {custom_sort $fileId $attrNames} $records >> a1: $fileId >> a2: $attrNames >> toSort1; {1} {stuff} >> toSort2: {2} {more stuff} >> { {2} {more stuff} } { {1} {stuff} } >> >> >> Thank you! >> >> >> ------------------------------------------------------------------------------ >> BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT >> Develop your own process in accordance with the BPMN 2 standard >> Learn Process modeling best practices with Bonita BPM through live >> exercises >> http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- >> event?utm_ >> source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF >> _______________________________________________ >> Tcl-mac mailing list >> tc...@li... >> https://lists.sourceforge.net/lists/listinfo/tcl-mac >> >> > |