Hi trekker_colin,
I think the following example code is what you are looking for:
pro readingtext
shapesfile='C:\path\to\file\test_texts.txt'
openr, lun, shapesfile, /GET_LUN
; Read one line at a time, saving the result into array
s=''
object = intarr(4)
shape = strarr(4)
i=0
WHILE NOT EOF(lun) DO BEGIN
READF, lun, n, s, format='(i1,1x,a6)'
object[i]=n
shape[i]=s
i=i+1
ENDWHILE
help, shape
print, shape
for i=0, 3 do begin
if (shape[i] eq 'circle') then shape[i]=1
if (shape[i] eq 'square') then shape[i]=2
endfor
print, shape
; Close the file and free the file unit
FREE_LUN, lun
end
Notice that this example is hardcoded so that the name strings have the same number of characters, i.e. 6.
Cheers,
Fernando
|