[futurebasic] Re: [FB] initialize an array

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2006 : Group Archive : Group : All Groups

From: Steve Crossman <mactech@...>
Date: Wed, 4 Jan 2006 10:33:08 -0500
Thank you Stu and Jay for your help and suggestions.

Too many things I do the slower way, albeit it works, but now is the  
time to tweak those 100,000 iteration loops for some speed :)

thanks again

~ steve

On Jan 4, 2006, at 3:25 AM, Jay Reeve wrote:

> Steve,
>
> For clearing arrays, I use the toolbox BLOCKZERO:
>
> DIM gtotals ( 50000 ) AS DOUBLE
> BLOCKZERO(@gTotals(0), 50001* SIZEOF(DOUBLE)) ' all done!
>
> For concatenating strings, here is one option which should be  
> plenty fast.
>
> LOCAL FN addStrings(@str1 AS PTR, @str2 AS PTR) ' adds str2 to str1  
> without overrun
>   DIM AS LONG L1, L2
>   L1       = str1.0`` ' get lengths
>   L2       = str2.0``
>   IF L1 + L2 > 255 THEN L2 = 255 - L1 ' check for overrun; truncate  
> if necessary
>   BLOCKMOVE str2 + 1, str1 + L1 + 1,  L2 ' move chars
>   str1.0`` = L1 + L2 ' set new length for str1
> END FN // = str2.0`` - L2 ' return number of chars not moved from  
> str2 (optional)
>
> hth,
>  e-e
>  =J= a  y
>   "
>
>
> On Tuesday, January 3, 2006, at 09:16  PM, Steve Crossman wrote:
>
>> Is there a quick way to initialize a variable array to zeros ?
>> where for the variable array below, I can set the entire array to  
>> zero
>>
>>  dim gtotals ( 50000 ) as double
>>
>> right now I do this
>>
>> for x = 1 to 50000
>> gtotals ( x ) = 0
>> next x
>>
>> I may do this many times and I am trying to speed this up.
>> should I use a dynamic array ?
>>
>> and one more thing.
>>
>> I want to find the fastest way to concatenate strings and ensure  
>> that when adding them together, their length doesn't exceed 255  
>> characters.  I know HOW to do this, but I am sure the way I am  
>> doing, it is not the fastest method possible.
>>
>> I need some Jay magic string handling here :)
>>
>> thanks
>>
>>
>>
>> .-.                       Steve Crossman                       .-.
>>
>>   \         .-.                               .-.         /
>>
>>    \       / \     .-.   _   .-.     / \       /
>>
>>     \     /   \   / \ / \ / \   /   \     /
>>
>>      \   /     \ /   `-' `-'   \ /     \   /
>>
>>       \ /       `-'   mactech@... `-'       \ /
>>
>>        `-'               http://macpos.com              `-'
>>
>>
>>
>>
>>
>> --
>> To unsubscribe, send ANY message to: futurebasic- 
>> unsubscribe@...
>>
>>
>
> --
> To unsubscribe, send ANY message to: futurebasic- 
> unsubscribe@...