Larry
unread,Nov 18, 2009, 3:08:01 PM11/18/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to GoogleSemWare TSE, TsePro
/***
At the risk of breaking the Weapon Shops of DRY principle (all due
deference to A. E. van Vogt and Knud van Eeden), this macro revisits the
sorting of non-aligned columns that the Staggered Column Sorter
(scs.mac) addressed earlier this year.
As you can tell, this is a much smaller macro (about 40 lines) that does
the same thing for text as the scs macro (over 400 lines).
Aside from the silly method, the problem with scs was that it attempted
to do too many unnecessary things, and to do them on both text and
number columns.
This macro only does text and only offers two sort options, case and
order.
The macro accepts the options in either the command line or at a prompt
if no command line options are given.
The macro to sort number columns will arrive in a later message.
***/
// macro source starts here...
// jigjagtextsort.s - a simpler jaggedy text column sorter
<ctrlshift x><t> execmacro("jigjagtextsort")
/***
Sometimes, simple is better.
This is a simpler, quicker version of the staggered column sorter of
earlier this year. That macro, scs.mac, was over 400 lines; this one is
only about 40. That macro also did numbers, but this one only does text.
The macro sorts a column of text even if the columns are not
left-aligned. After the sort, the data in the columns remains
in its original horizontal position on each line (not aligned).
The sort options can be entered either on the command line, as in a
macro execmacro() use, or by using the prompt if no command line
parameter are entered.
The macro recognizes two sort options, ignore case or descending order.
If no options are added, the default sort is case-sensitive in ascending
order.
For commandline example:
jigjagcolsort -i-d (one or both or none)
At the prompt, the same two options are available.
The macro will sort text that is aligned or not aligned. The not aligned
text can be right-aligned, center-aligned, or have random alignment.
Assumptions:
1. that the column to be sorted is a column marked block;
2. number of lines limit: 65000;
3. the sort acts on the left-most 255 characters in the marked block.
***/
proc main()
string p[6]=Lower(Query(MacroCmdLine))
string c[2]=""
string o[2]=""
if p==""
p="-i"
if ask("Sort Options: (-i)gnore case, (-d)escending, ESC=Quit",p)
and length(p)
else
sound(40,40)
warn("Cancelled.")
goto ending
endif
endif
if pos("i",p)
c="-i"
endif
if pos("d",p)
o="-d"
endif
if isblockmarked()==_column_
pushposition()
gotoblockbegin()
pushblock()
copyblock()
execmacro("adjust left")
execmacro("sort "+c+o)
delblock()
popblock()
popposition()
else
sound(40,40)
warn("No Block. Ending.")
endif
sound(11000,10)
message("(jigjagtextsort) Finished.")
goto ending
ending:
end
// end of macro source.....