<HTML><FONT FACE=arial,helvetica><FONT SIZE=2 FAMILY="SANSSERIF" FACE="Arial" LANG="0">Would this run faster?<BR>
<BR>
on mouseUp<BR>
put fld "data" into tOrigData<BR>
set the itemdelimiter to TAB<BR>
create image<BR>
put it into tID<BR>
set the width of tID to tWidth<BR>
set the height of tID to tHeight<BR>
<BR>
put empty into iData<BR>
repeat for each line l in tOrigData<BR>
repeat for each item i in l<BR>
if i > 0 then put binaryEncode("CCCC",0,0,255,0) after iData ---make green<BR>
else put binaryEncode("CCCC",0,0,0,255) after iData --- make blue<BR>
end repeat<BR>
end repeat<BR>
set the imageData of tID to iData<BR>
end mouseUp<BR>
<BR>
Philip Chumbley<BR>
<BR>
<BR>
<BLOCKQUOTE TYPE=CITE style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">Hello,<BR>
<BR>
<BR>
I have modified my script to produce the appropriate image and it works<BR>
perfectly apart from one thing...<BR>
<BR>
<BR>
The script looks like this. Basically it loops across some tab delimited<BR>
data (which is elevation data, that is a height measurement). If that point<BR>
is above 0, ie above sealevel it makes it green (ie solid land). If it is 0<BR>
or below zero it makes it blue (ie under water)<BR>
<BR>
on mouseUp<BR>
## get the data<BR>
put fld "data" into tOrigData<BR>
set the itemdelimiter to TAB<BR>
<BR>
put 571 into twidth -- data is 571 across<BR>
put 429 into tHeight -- data is 429 lines in height<BR>
<BR>
## create the image<BR>
create image<BR>
put it into tID<BR>
<BR>
set the width of tID to tWidth<BR>
set the height of tID to tHeight<BR>
<BR>
put empty into iData<BR>
repeat with j = 1 to tHeight<BR>
repeat with i = 1 to tWidth<BR>
put item i of line j of tOrigData into tDataValue<BR>
if tDataValue > 0 then -- above sea level<BR>
put binaryEncode("CCCC",0,0,255,0) after iData ---make green<BR>
else -- point is below sea level<BR>
put binaryEncode("CCCC",0,0,0,255) after iData --- make blue<BR>
end if<BR>
end repeat<BR>
end repeat<BR>
set the imageData of tID to iData<BR>
end mouseUp<BR>
<BR>
<BR>
The only problem is the speed of execution. It is painfully slow. A bit of<BR>
checking reveals that it is the line:<BR>
<BR>
put item i of line j of tOrigData into tDataValue<BR>
<BR>
<BR>
that is causing the bottleneck. There must be a better way to do this? In<BR>
the past I have never really bothered optimising these sort of repeat loops<BR>
as it has always been fast enough for me. With 571 x 429 data points though<BR>
it is just too slow. Does any one have any suggestions?<BR>
<BR>
<BR>
Thanks<BR>
<BR>
<BR>
Michael Crawford</BLOCKQUOTE><BR>
<BR>
</FONT></HTML>