----boundary-LibPST-iamunique-1104530716_-_-
Content-type: text/plain
Carl,
You may modify 'My' in any way you wish. That's what its for!
-Doug Danforth
On 7/26/2012 7:07 PM, Carl Glassberg wrote:
Hello Rainer:
A possible simple approach might be to see if you can adapt the following single file "copy" example, which requires you to use Douglas Danforth's amazing and excellent subsystem ["My"] available from Howard Zinn's website CPC at
I hope Douglas Danforth doesn't object, but I adapted his "My.Files" examples of separate read and write and created a single combination example for copying a single file.
You will need to adapt the following so each file to be merged is copied to a singe output file in the order you wish the concatenation to occur.
Danforth has "Open" commands provided for both input and output in his Files library so you should have more flexibility in the filenames then this example. You should be able to avoid the interactive file prompting of the example if you already know the input and output filenames.
There will be 1 output file which remains open until the input files have been copied. Presumably after each input file is copied, it is closed, so only 1 input need be open at a time.
These are the details you would work out for yourself when you modify the example.
I have to give credit though to Professor K.N. King because there is an example of concatenating input files in his book "Modula-2: A Complete Guide", available from Amazon.
I claim no credit for merging Danforth's read/write examoles and hope he doesn't mind.
Sincerely
Carl Glassberg
Std encoder/decoder appears not to be working on my system, some problem with extra end-of-lines, so here is the program text:
Copyright © 2012,
by Douglas G. Danforth
Version 20-Jan-2012
This program is free software; you can redistribute it and/or modify it under the terms of the "BlackBox Component Builder Open Source License".
MODULE MyTest;
(* modified from Douglas Danforth's separate read/write examples by Carl Glassberg *)
IMPORT MyFiles, Stores;
PROCEDURE Copy *;
VAR rc: MyFiles.ReadController; rd: Stores.Reader;
wc: MyFiles.WriteController; wr: Stores.Writer;
ch: CHAR;
BEGIN
rc.SetExtension("txt");
IF rc.OpenDialog(rd) THEN
wc.SetExtension("txt");
IF wc.OpenDialog(wr) THEN
rd.ReadChar(ch);
WHILE ~rd.rider.eof DO
wr.WriteChar(ch);
rd.ReadChar(ch)
END (* while *);
wc.Close
END (* if *);
rc.Close
END (* if *)
END Copy;
END MyTest .
---------------------
Hi all,
in the near future I will have to programatically merge two or three >ASCII files into one new file.
Does anybody have a hint how to do this in a simple manner ?
I had a look at the interface of module WinApi but could not find a >procedure for this task.
Reading the files line by line into a buffer and writing the contents to >a new file seems to be a bit nasty.
Best regards,
Rainer
----
----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy
---- To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy
----boundary-LibPST-iamunique-1104530716_-_-
Content-type: text/html
Carl,
You may modify 'My' in any way you wish. That's what its for!
-Doug Danforth
On 7/26/2012 7:07 PM, Carl Glassberg
wrote:
Hello Rainer:
A possible simple approach might be to see if you can adapt the following single file "copy" example, which requires you to use Douglas Danforth's amazing and excellent subsystem ["My"] available from Howard Zinn's website CPC at <http://www.zinnamturm.eu/>
I hope Douglas Danforth doesn't object, but I adapted his "My.Files" examples of separate read and write and created a single combination example for copying a single file.
You will need to adapt the following so each file to be merged is copied to a singe output file in the order you wish the concatenation to occur.
Danforth has "Open" commands provided for both input and output in his Files library so you should have more flexibility in the filenames then this example. You should be able to avoid the interactive file prompting of the example if you already know the input and output filenames.
There will be 1 output file which remains open until the input files have been copied. Presumably after each input file is copied, it is closed, so only 1 input need be open at a time.
These are the details you would work out for yourself when you modify the example.
I have to give credit though to Professor K.N. King because there is an example of concatenating input files in his book "Modula-2: A Complete Guide", available from Amazon.
I claim no credit for merging Danforth's read/write examoles and hope he doesn't mind.
Sincerely
Carl Glassberg
Std encoder/decoder appears not to be working on my system, some problem with extra end-of-lines, so here is the program text:
Copyright © 2012,
by Douglas G. Danforth
Version 20-Jan-2012
This program is free software; you can redistribute it and/or modify it under the terms of the "BlackBox Component Builder Open Source License".
MODULE MyTest;
(* modified from Douglas Danforth's separate read/write examples by Carl Glassberg *)
IMPORT MyFiles, Stores;
PROCEDURE Copy *;
VAR rc: MyFiles.ReadController; rd: Stores.Reader;
wc: MyFiles.WriteController; wr: Stores.Writer;
ch: CHAR;
BEGIN
rc.SetExtension("txt");
IF rc.OpenDialog(rd) THEN
wc.SetExtension("txt");
IF wc.OpenDialog(wr) THEN
rd.ReadChar(ch);
WHILE ~rd.rider.eof DO
wr.WriteChar(ch);
rd.ReadChar(ch)
END (* while *);
wc.Close
END (* if *);
rc.Close
END (* if *)
END Copy;
END MyTest .
---------------------
Hi all,
in the near future I will have to programatically merge two or three >ASCII files into one new file.
Does anybody have a hint how to do this in a simple manner ?
I had a look at the interface of module WinApi but could not find a >procedure for this task.
Reading the files line by line into a buffer and writing the contents to >a new file seems to be a bit nasty.
Best regards,
Rainer
----
----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to Received on Fri Jul 27 2012 - 07:30:33 UTC