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

Home » Public Forums » archive » populating an array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
populating an array [message #48167] Thu, 30 March 2006 07:34 Go to next message
subir.vasanth is currently offline  subir.vasanth
Messages: 5
Registered: March 2006
Junior Member
Greetings!

I was wondering if there was a more efficient way to populate an array
created using the MAKE_ARRAY function. This is how I am populating the
array right now -

data = BYTARR(202000L)
; populate byte array with valid data from some input source
array = MAKE_ARRAY(1000,101, Type = 2)
offset = 0L
FOR k = 0L, 100999L DO BEGIN
array(k) = FIX(data, offset)
offset = offset + 2
ENDFOR

Is there a way I can populate 'array' without using a loop to populate
each element, and instead do a array = FIX(data)??

Thanks,
subir
Re: populating an array [message #48209 is a reply to message #48167] Thu, 06 April 2006 13:38 Go to previous message
subir.vasanth is currently offline  subir.vasanth
Messages: 5
Registered: March 2006
Junior Member
Thanks for your response Greg. I was trying to read a stream of bytes
from a socket and populate an array with that data. I think CP's
suggestion is what I was looking for .

Thanks!
Re: populating an array [message #48221 is a reply to message #48167] Thu, 06 April 2006 06:24 Go to previous message
greg michael is currently offline  greg michael
Messages: 163
Registered: January 2006
Senior Member
Looks to me like you have an array of integers which you accidentally
read into a byte array, and now you'd like to put things back in order.
The best way would be to read the data into an intarr of the right
dimensions in the first place. If it's too late, write out your byte
array to a file:

openw,1,filename
writeu,1,data
close,1

and read it back how you want it:

array = MAKE_ARRAY(1000,101, Type = 2)
openr,1,filename
readu,1,array
close,1

You may need to use swap_endian if it comes out byte-swapped.

regards,
Greg
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: 3d scatter plot
Next Topic: Re: populating an array

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

Current Time: Wed Oct 08 19:34:28 PDT 2025

Total time taken to generate the page: 0.00722 seconds