home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS - Coast to Coast
/
simteldosarchivecoasttocoast2.iso
/
sprint
/
appenfil.zip
/
APPENFIL.SPM
Wrap
Text File
|
1993-08-31
|
4KB
|
96 lines
Append a Region to a File
The "WriteSelected" macro in the Borland interface allows you to
WRITE selected regions (or columns) to a file. The following
macros use the DOS copy command to extend that capability to
APPEND to a file.
Description of Included Macros
-----------------------------------------------------------------------
*ScratchFile* is for convenience. It is a general purpose macro
for creating temporary filenames. An argument to ScratchFile
(e.g., 4 ScratchFile) puts the temporary filename into Q-register
specified by the argument (e.g, Q4 in this example).
*AppendCommand* is only for convenience. It simply composes the
command to be passed to DOS. It is hardcoded to use QD for the
command, currently expects the filename of the to-be-appended
file to be in Q0, and Q4 holds the name of a temporary file.
*BlockWrite* is based on Borland's WriteSelected (from sp.spm),
with additional tests for the append command. If the argument to
BlockWrite is non-zero, then it will append the region to a file
(or create the file if it does not exist). (All the action is
here. You could easily collapse ScratchFile and AppendCommand
into BlockWrite if you wanted.) BlockWrite is also generalized
so that you can enter wildcards (or no filename at all) to get a
menu to choose from. The "overwrite?" test works in all cases if
you are writing a file. It is skipped over in the case of append.
*BlockAppend* is for convenience so that it can be assigned to a
key. Its only function is to pass a value to BlockWrite.
-----------------------------------------------------------------------
; for convenience - composing an append copy
;; ideally "G:" is a ramdisk
ScratchFile : ->x (set qnumber x "G:\\xxxxzzzz.$$$") ;
AppendCommand :
mark {to QD clear "command /c copy " insert Q0 "+" insert Q4 " "insert Q0}
BlockWrite : ->int appendfile
if !select (NoBlock return)
set Q0 ""
appendfile ? (message "\nAppend" 4 Scratchfile)
: message "\nWrite"
message " block to: " set Q0
if !length Q0 (16 set Q0 flist "*") ; if no file entered, then allow menu choice
16 set Q0 flist Q0 ; check for unique choice or wildcards
if (!(32 exist Q0) || (if !appendfile ask "Overwrite existing file? " else true) ) {
if !ColMode {
appendfile ? {writeregion togmark Q4 AppendCommand call QD}
: (writeregion togmark Q0)
mark {
if (buffind Q0) ReReadFile ; if file was open, reread
}
}
else {
ColCopy ; get column to QH
mark {
to QH ; get into column buffer
appendfile ? {write Q4 AppendCommand call QD }
: if length (write Q0) ; and write it
if (buffind Q0) ReReadFile ; if file was open, re-read
}
}
}
; dummy command for the menus/keys
BlockAppend : 1 BlockWrite
-----------------------------------------------------------------------
Conditions of Use
Use the code as you want, don't sell it, and give credit where
due. Let me know if you try it out, find problems, make
improvements, etc. If get some programming ideas/code
from all this, then I would be grateful if you would share some
of your own interesting macros or formatter hacking with me. If
you don't have any code to share, a postcard or email will be
just fine. Enjoy.
Seth Chaiklin
Institute of Psychology
University of Aarhus
8240 Risskov
DENMARK
email: psykseth@aau.dk
fax: +45 (86) 17 59 73
31 August 1993