Big typed constant array definition? 
Author Message
 Big typed constant array definition?

Hi!

At the moment I am using constant array definition:

const arrayname: array[0..255] of dword = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);

I wonder if there is some more sensible way to get an array filled with
same values (besides using FOR cycle)? I am using FreePascal compiler...

Reaper



Sat, 29 Oct 2005 05:36:30 GMT  
 Big typed constant array definition?

Quote:

> At the moment I am using constant array definition:

> const arrayname: array[0..255] of dword = (0,...,0);

> I wonder if there is some more sensible way to get an array filled with
> same values (besides using FOR cycle)? I am using FreePascal compiler...

Hm...
what about

var arrayname: ...
FillChar(arrayname,sizeof(arrayname),0);

//or better: (FPC only and sizeof(...) must be even)
FillWord(arrayname,sizeof(arrayname) div 2,0);

Wolf



Sat, 29 Oct 2005 06:33:43 GMT  
 Big typed constant array definition?

Quote:


>> At the moment I am using constant array definition:

>> const arrayname: array[0..255] of dword = (0,...,0);

>> I wonder if there is some more sensible way to get an array filled with
>> same values (besides using FOR cycle)? I am using FreePascal compiler...

> Hm...
> what about

> var arrayname: ...
> FillChar(arrayname,sizeof(arrayname),0);

> //or better: (FPC only and sizeof(...) must be even)
> FillWord(arrayname,sizeof(arrayname) div 2,0);

Hmm, fpc is a 32-bitter,  (array must be divisable by 4)

FillDWord (arrayname(sizeof(arrayname) div 4,0);



Sat, 29 Oct 2005 17:53:30 GMT  
 Big typed constant array definition?


Quote:


> >> At the moment I am using constant array definition:

> >> const arrayname: array[0..255] of dword = (0,...,0);

> >> I wonder if there is some more sensible way to get an array filled with
> >> same values (besides using FOR cycle)? I am using FreePascal compiler...

> > Hm...
> > what about

> > var arrayname: ...
> > FillChar(arrayname,sizeof(arrayname),0);

> > //or better: (FPC only and sizeof(...) must be even)
> > FillWord(arrayname,sizeof(arrayname) div 2,0);

> Hmm, fpc is a 32-bitter,  (array must be divisable by 4)

> FillDWord (arrayname(sizeof(arrayname) div 4,0);

Ok, but what is faster, FillDWord or constant array definition in the
beginning? I thought there would be some shorter way to write all those
zeros, like (0,...,0)?

Reaper



Mon, 31 Oct 2005 03:17:38 GMT  
 Big typed constant array definition?

Quote:

>> FillDWord (arrayname(sizeof(arrayname) div 4,0);

> Ok, but what is faster, FillDWord or constant array definition in the
> beginning? I thought there would be some shorter way to write all those
> zeros, like (0,...,0)?

Constant. Unless it gets that large that it affects program loading, which
is hard to estimate, but probably not until 100's of kbs.


Mon, 31 Oct 2005 04:44:26 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Variable size array pointer type definition

2. serious compiler error - typed constants

3. Help witth Legal type definitions

4. serious compiler error - typed constants

5. typed constants with GNU pascal?

6. Behaviour of local typed constants

7. Possible Bug in Typed Constants

8. TP7: limit to typed constants?

9. Constants for logical field types idapi.h

10. Constant and Case type error.

11. Typed Constants

12. type definition....

 

 
Powered by phpBB® Forum Software