comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Re: Editing Ascii File

Re: Editing Ascii File
type: item
description: 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
creator: knipp
date: 1995-06-13T07:00:00-00:00