Creating multiple files with increasing numbers
Author |
Message |
elitegundam
|
Posted: Thu Jun 10, 2010 6:48 am Post subject: Creating multiple files with increasing numbers |
|
|
In short, I'm trying to create a program that will split an ebook into individual chapters. All the files I'll be working with are already in .txt format.
I'm having some troubles with the open : get command, such as length (There's a lot of words in an ebook). Most of them I should be able to get around with some loops, and the seek/tell commands.
My big problem is (or will be) the file names for each chapter. I'd like to have them "chapter01, chapter02" etc. I've looked through a lot of the tutorials, and owe a huge debt of gratitude to many of the authors, but I haven't been able to find anything that might help with this problem.
As far as I can tell, I can only add a string to the end of a filename, and for increasing numbers the variable would need to be an number (int or real).
I'm sure there's an easy solution that I just haven't found yet, so any help would be appreciated. As a last resort, I think I can use chr to name the chapters "chaptera, chapterb" etc... |
|
|
|
|
|
Sponsor Sponsor
|
|
|
elitegundam
|
Posted: Thu Jun 10, 2010 8:13 am Post subject: RE:Creating multiple files with increasing numbers |
|
|
Update:
The problem I thought was due to size, was actually caused by quotation marks in the book. I'm not sure if there's a way to bypass that with "get", but I changed them in the book, not the most feasible solution, but enough for the testing stage.
It's now a fairly small program, looping until it hits the word "chapter", then restarting the loop (ideally writing to a new file each time).
The only problem I have now is writing to a different file for each chapter, ideally with sequential numbers. |
|
|
|
|
|
Insectoid
|
Posted: Thu Jun 10, 2010 8:19 am Post subject: RE:Creating multiple files with increasing numbers |
|
|
use the intstr() command. It converts an integer to a string. |
|
|
|
|
|
elitegundam
|
Posted: Thu Jun 10, 2010 9:10 am Post subject: Re: Creating multiple files with increasing numbers |
|
|
Thanks, that's exactly what I needed!!
I came across it in one of the tutorials, but was a bit confused about what it did (should have paid a bit more attention).
It's been close to 10 years since I used Turing, looks like I've got a lot to re-learn if I plan on doing anything else, as well as a lot of "new" features. |
|
|
|
|
|
|
|