From: Dr J R Stockton on 22 Feb 2010 12:55 In microsoft.public.scripting.vbscript message <OcM5PGErKHA.4220(a)TK2MSFT NGP05.phx.gbl>, Sat, 13 Feb 2010 01:14:49, francois <francois(a)NoSpam.fr> posted: > >I just would like modify the number in the firt line (2345), without >put in the memory the rest of the text or create a new temporay file? >Is it possible? > >I ask this question because I want to use this script with lot of text >files and this text files are quite big. That is easily enough done in Borland Pascal or Delphi, which can alter parts of an existing binary file, since it has been established that the first line can be of constant length. Therefore, it will be equally easy in C or C++ or any well-designed general purpose programming language. If we still believe that disc sectors are 512 bytes long, it will be most efficient, probably, to read the first 512 bytes into an array of bytes, alter where required, and write back. Remember that any file can be treated as a text file or a binary file; one just has to be careful not to break any internal structure. -- (c) John Stockton, nr London UK. ?@merlyn.demon.co.uk BP7, Delphi 3 & 2006. <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links; <URL:http://www.bancoems.com/CompLangPascalDelphiMisc-MiniFAQ.htm> clpdmFAQ; NOT <URL:http://support.codegear.com/newsgroups/>: news:borland.* Guidelines
From: francois on 26 Feb 2010 16:00 mayayana a �crit : > That seems doable. So you just need to write > the first 20 bytes/characters, regardless of the number > you need to write.You can't do it with > Textestream/VBScript Ok, that's clear. > but probably with AutoIt, > JSBin, or something similar. You'd need to test it. > I think that a file can be opened and bytes written > without loading the whole thing. I think JSBin > works that way. But I'm not certain. Ok. Perhaps I'll test it, but... >> I hope it's clear this time. :-) > > It's still not clear to me why anyone would write > files that are too big to handle, but that's really > your decision. .... Ok, you are right, you convinced me. I'm going to change my way to create my .log files. :-) -- Fran�ois Lafont
From: francois on 26 Feb 2010 16:08 Todd Vargo a �crit : > What is the largest file size you need to modify? Perhaps you are being > overly concerned about reading the entire file into memory. It's 185 kio and I have 700 text files. But as I said in my previous message, I'm going to change my way to create my ..log files. I'm going to create a specific text file (%username%-sum.log) which will just contain the "sum" number. Thanks to all of you for your help. -- Fran�ois Lafont
From: Todd Vargo on 26 Feb 2010 16:41 francois wrote: > Todd Vargo a �crit : > >> What is the largest file size you need to modify? Perhaps you are being >> overly concerned about reading the entire file into memory. > > It's 185 kio and I have 700 text files. But as I said in my previous > message, I'm going to change my way to create my .log files. > > I'm going to create a specific text file (%username%-sum.log) which will > just contain the "sum" number. How many bytes is a "kio"? -- Todd Vargo (Post questions to group only. Remove "z" to email personal messages)
From: francois on 26 Feb 2010 16:56
Todd Vargo a �crit : >>> What is the largest file size you need to modify? Perhaps you are >>> being overly concerned about reading the entire file into memory. >> >> It's 185 kio and I have 700 text files. But as I said in my previous >> message, I'm going to change my way to create my .log files. >> >> I'm going to create a specific text file (%username%-sum.log) which >> will just contain the "sum" number. > > How many bytes is a "kio"? 1 kio = 1024 bytes 185 kio = 189440 bytes -- Fran�ois Lafont |