home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR4
/
TEXMAC.ZIP
/
SORT.SPM
< prev
next >
Wrap
Text File
|
1991-01-05
|
3KB
|
89 lines
; Copyright (c) 1988 Borland International. All Rights Reserved
;
; NAME: SORT.SPM
; VERSION: 1.01
; DESCRIPTION: Sort macros
; LAST UPDATE: September 9, 1988
;
; NOTES: This file must be compiled and loaded AFTER CORE.SPM.
; USES EXTERNAL SORT PROGRAM SPSORT.EXE
;----------------------------------------------
; Q register usage:
; see SP.SPM for register and mark tables
;----------------------------------------------
; CONTENTS:
; SECTION: Routines whose definitions are to be removed.
; SECTION: Routines that MUST exist for the compiler to work
; SECTION: Variables -- all the variables are declared here
; SECTION: Forward declarations -- In order to keep the main list
; of macros in alphabetical order, a few of them have to be
; declared ahead of time -- like a FORWARD declaration
; in Pascal
; SECTION: Automatically-called macro definitions (Main, Init,
; EditKeys, MacroKeys, etc.)
; SECTION: General and command macros in alphabetical order
; SECTION: Menus (leaves first, root last)
; SECTION: Control and function keys
;----------------------------------------------
#define RevOrder 0 ; sorting order
#define Was ; was a block or a column
; --------------------------------------------------
; Forward reference for Help
;--
; now I have pcsort, might prefer it here instead.
SortHelp:
DoSort :
; check to see if spsort.exe sorting program is present
set Q0 "spsort.exe" NeedDisk
if modf WantSave
0 QTMP ; create temp file in home directory in Q0
; spsort is present, so do the sort...
select case {
1 ;--- write block to external file
if (current != '^J') tosol ; Take only entire line
swapmark
line->int vline
swapmark
if line=vline return ; Only one line selected
writeregion togmark Q0
; need to handle home dir. here
select -> Was
RegionErase
Unselect,
2 ;--- write Column to external file
ColSDelete ; call column macro deletion in QH
swapmark
mark ( to QH write Q0 )
select->Was
Unselect
}
;--- now call external sorting program
status "Sorting..."
if RevOrder { 32 call "spsort " Q0 " -r" }
else { 32 call "spsort " Q0 }
if (Was = 1) read Q0
else { ; write the sorted file in column buffer
mark (
to QH clear
if !select $ read Q0
)
ColInsert ; insert the sorted column at point
}
;--- delete temporary files
fdelete Q0
SortMenu :
if !select NoBlock
menu "Sort" (
"Ascending" SortHelp 0,
"Descending" SortHelp 1
)->RevOrder
abortkey->int OldAbort
-1->abortkey
DoSort
OldAbort->abortkey