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

Home » Public Forums » archive » Writing a modified .txt file issue
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: Writing a modified .txt file issue [message #85379 is a reply to message #85377] Mon, 29 July 2013 17:54 Go to previous messageGo to previous message
Heinz Stege is currently offline  Heinz Stege
Messages: 189
Registered: January 2003
Senior Member
On Mon, 29 Jul 2013 17:18:31 -0600, David Fanning wrote:

> I can't get this code by Heinz to work at all:
>

Below is an example with some Explanations.

Cheers, Heinz


; Here is a string array which could come from a file:
nLines=10
word='text'+strtrim(indgen(nLines)+1,2)+$
string(findgen(nLines)*2.+100.)+$
string(lindgen(nLines)*5L+200L)
print,'This is our input:'
print,word,form='(a)'
;
; Make a structure for the result:
nColumns=3
struct={text:'',float:0.,long:0L}
data=replicate(struct,nLines)
;
; Loop over all columns but the last one:
for i=0,nColumns-2 do begin
;
; Get the end positions of the first column
pos=strpos(word,' ')
;
; Put the first column into the i-th tag of the structure
data.(i)=strmid(word,0,transpose(pos))
;
; Remove the first column (and trailing blanks) from the input
; array
word=strtrim(strmid(word,transpose(pos)),1)
;
; Continue the loop with the next column
end
;
; Copy the last column into the structure
data.(nColumns-1)=word
;
; Check the result
print,'This is the result structure:'
for i=0,nLines-1 do print,data[i]
;
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Find all user-defined structure definitions
Next Topic: Multiple plots with plot function

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

Current Time: Fri Oct 10 14:07:09 PDT 2025

Total time taken to generate the page: 1.03872 seconds