comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Editing Ascii File
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Editing Ascii File [message #4525] Tue, 13 June 1995 00:00
knipp is currently offline  knipp
Messages: 68
Registered: January 1993
Member
In article a65@nlcnews.nlc.state.ne.us, tskill@monarch.papillion.ne.us (Thomas Skill) writes:
> I Currently have an Ascii file containing a filename per line. What i
> would like to do is be able to go in the file and delete a line with out
> effecting other lines. Also i would like to be able to add a line
> anywhere in the file with out effecting other lines. Ive been having
> problems using:
>
> printf,file_lun,newstring
>
> to write the newstring in the file. i use a simple for loop to get the
> filepointer to the place i want it to then do the printf. Is this the
> right approach for inserting and deleting lines in an ascii file for
> PVWave?? Thanks!


Asuming your ascii-text is not too large try the following :

; read entire file into string-array:
; method a:

text_file = '...' ; name of file with text
ntext = ... ; number of lines
line = '' ; pre-defined line to read
text = strarr(ntext) ; string-array

openr, unit, text_file, /get_lun
for i=0l, ntext-1l do begin
readf, unit, line
text(i) = line
endfor
free_lun, uni

; method b: (UNIX)

spawn, ['/bin/cat', text_file], text, /noshell




; do your modifications, p.e.

text(x) = strlowcase(text(n)



; delete old file, write new (a backup prior to this wouldn't be a bad idea)


openw, unit, text_file, /get_lun
for i=0l, ntext-1l do printf, unit, text(i)
free_lun, unit







Karlheinz

Karlheinz Knipp knipp@ipi.uni-hannover.de
[Message index]
 
Read Message
Previous Topic: Re: How to make GIF file (2) ?
Next Topic: post script printing

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:50:01 PDT 2025

Total time taken to generate the page: 0.00419 seconds