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

populating an array
type: item
description: 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
creator: subir.vasanth
date: 2006-03-30T15:34:03-00:00

Re: populating an array
type: item
description: 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
creator: greg michael
date: 2006-04-06T13:24:29-00:00

Re: populating an array
type: item
description: 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!
creator: subir.vasanth
date: 2006-04-06T20:38:41-00:00