May 04, 2024, 03:07:04 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Use of wild cards

Started by AdrianFox, October 17, 2010, 11:30:42 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

AdrianFox

 :-[  Sorry if this is rather stupid, but I'm just getting back to some programming after the long spring and summer absence, so the old grey matter is rather curdled, having forgotten almost everything in the meantime.
I'm just trying to do something really simple which is to concatenate some text files into a single text file, as you would  accomplish in a DOS batch file with 'copy *.txt  new.txt '

Why doesn't the following work?

               copyfile "f:\\garden\\notes\\*.txt", "F:\\garden\\notes\\garden.nts",0
                                        'view the created file...
system "notepad.exe","f:\\garden\\notes\\garden.nts"


It works in DOS as a batch file but I end up with an empty file when calling it from the program.  It works of course if I use a specific file name instead of '*.txt'.


How do I concatenate a series of numbered txt files into a single text file if I can't use the wild card?  I know I can't crudely call DOS commands from EB, but how do I do this?






               
Adrian Fox

LarryMc

just off the top of my head to do it 100% IWBasic

open the output file for write and close it.
doing that will make sure the output file exists AND is empty

open the output file again for append
use FINDOPEN and FINDNEXT to find each of your source files
read each source file a line at a time and append the line to the destination file

after all source files have been read and added to output file close output file and do FINDCLOSE

then use your system to pen notepad.


........
or

use Fletchie's ctl.lib and use the APPENTEXT command in conjunction with the FINDOPEN/FINDNEXT/FINDCLOSE commands as above. Using this method requires that each source file be no larger than 32k


.......
or

you can use FINDOPEN/FINDNEXT/FINDCLOSE  to find all the path names

open an output file named something.BAT and write "copyfile blah...." (DOS command) then close file
then do  system something.bat like what you are doing for notepad.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

AdrianFox

Thanks for the very prompt reply Larry.  Using FindOpen, FindNext, FindClose should do what I want.   It's probably much easier just to use a batch file anyway, but I was trying to do it all in IWBasic.
Regards and best wishes,
:)
Adrian Fox

billhsln

Here is a copy of the program that will do what you are looking for.

Bill
When all else fails, get a bigger hammer.

AdrianFox

Thanks Bill, that does exactly what I want.   Having the code to work through will also help me understand what is going on and I can then customise it exactly to my requirements.
Really appreciate the help!
:)
Adrian Fox