This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

generator script

Old posts that have not been replied to for several years.
Locked
User avatar
duofruo
Halfop
Posts: 94
Joined: Thu Oct 23, 2003 3:17 pm
Location: Ploiesti@.ro
Contact:

generator script

Post by duofruo »

Let`s say that exist 3 txt documents. I need a script that will read all of this documents, and generate a file whith all of this like this.
For example. The 1st file contains :
bot
shell
tcl
The 2nd contains
member
profile
faq
And the 3rd contains
code
search
help

I want that the tcl generate the 4 files that should be like this :
bot:member:code
shell:profile:search
tcl:faq:help

Thx
Embrace The Inevitable
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: generator script

Post by user »

duofruo wrote:I want that the tcl generate the 4 files that should be like this :
bot:member:code
shell:profile:search
tcl:faq:help
Do you want tcl to just make up the contents of the 4th file? And how do you name the output files? Did I misunderstand something?

Code: Select all

set f1 [open file1]
set f2 [open file2]
set f3 [open file3]
set i 0
while {[gets $f1 1]>0 && [gets $f2 2]>0 && [gets $f3 3]>0} {
  set out [open "out[incr i]" w]
  puts $out $1:$2:$3
  close $out
}
close $f1
close $f2
close $f3
(if you want it all in one file, just move the opening/closing of the output file outside the loop)
Have you ever read "The Manual"?
User avatar
duofruo
Halfop
Posts: 94
Joined: Thu Oct 23, 2003 3:17 pm
Location: Ploiesti@.ro
Contact:

Post by duofruo »

Yes, thanks but i need that all the lines to be generated to the same file, not every line to diferent file
Embrace The Inevitable
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

duofruo wrote:Yes, thanks but i need that all the lines to be generated to the same file, not every line to diferent file
...and?
Have you ever read "The Manual"?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Don't be lazy and follow user's example and figure out yourself what stuff should be removed to make it write just one file.. seesh..
Once the game is over, the king and the pawn go back in the same box.
Locked