From: Stephan H. <ste...@gm...> - 2015-04-23 07:54:56
|
Hi Jean-Christian, This should work: lsort -command [list custom_sort $fileId $attrNames] $records You can play around with: puts {custom_sort $fileId $attrNames} puts [list custom_sort $fileId $attrNames] to understand the difference between those two. 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 > > |