/***
Okay, the jigmerge.s will do as it says, but, unfortunately, there could
be a problem. :}
Say your disk has 25 files named logfile.001 to logfile.025 but
logfile.010 is missing. Jigmerge will stop at logfile.009.
This jigmerge2.s uses a different approach. This macro places a bare
directory of the disk in drive A: into a file, then loads the file and
processes each filename by inserting it into the merge file in the
sorted order they appear on the disk. This should result in a proper
merging of the files sequentially from lowest extension to highest
extension.
I also added the assigned key <ctrlshift x> to make executing the macro
a bit easier.
And, I also added an automatic filenaming routine. The filename will use
the name "lfdisk.###" with ### being the buffer number of the file. The
macro will also use your TSE home path in the filename. You can comment
it out if you like.
(NOTE: For the merge file naming, the expectation is that your will do
all of your merging during one TSE session. Otherwise, there could be a
naming conflict since the naming uses the buffer number of the mew
merged file as its extension.)
As before, the assumption is that you are getting files from a disk on
drive A: and that the file extensions are numeric from a low number like
.001 up to a possible high number of .999. Also, ALL of the files on any
single disk will be merged even if they do not have the numeric
extension...this can easily be changed to ONLY do numeric extensions,
but the assumption is that these are the only files on your disks to be
merged.
Execute the macro for each disk you place in drive A:.
***/
// jigmerge.s - merge files on disk to one file in tse
<ctrlshift x> execmacro("jigmerge2")
proc main()
string tmpfn[_maxpath_]=loaddir()+"logfile.tmp" // the a: directory list
string fn[_maxpath_]="" // each filename in tmpfn list
integer tb=0 // the target merge file buffer id
integer wb=0 // the tmpfn buffer id
integer count=0 // total files merged
tb=newfile() // create file to put merged files
// merge file naming routine
changecurrfilename(loaddir()+"lfdisk."+format(str(tb):3:"0"))
// my test directory line
//dos("dir "+loaddir()+"mymac\jigp*rev1*.s /b > "+tmpfn,_dont_prompt_) // my
test line
// get directory of disk A:
dos("dir a:\logfile.* /b > "+tmpfn,_dont_prompt_) // for disk A:
wb=editfile(tmpfn)
begfile()
// merge the disk a: files to one file in numeric order
repeat
unmarkblock()
fn=gettext(1,currlinelen())//loaddir()+"mymac\*rev1"+format(str(i):3:"0")+".s"
// test line
gotobufferid(tb)
endfile()
begline()
addline()
addline(format("*":query(rightmargin):"*")) // merged text separator
begline()
addline(fn) // merged text filename
addline()
addline()
insertfile(fn,_dont_prompt_) // insert the file
count=count+1
if keypressed() goto ending endif
gotobufferid(wb)
until not down()
goto ending
ending:
if wb
abandonfile(wb)
endif
gotobufferid(tb)
begfile()
sound(9000,90)
updatedisplay()
warn(str(count)+" Files Were Merged. ") // total files merged
unmarkblock()
end
-----Original Message-----
From: Clueless in Seattle
Sent: Sunday, August 26, 2012 12:22 PM
To: SemWare TSE Pro text editor
Subject: [TSE] How to merge multiple text files in TSE 2.5 for DOS?