Link to home
Start Free TrialLog in
Avatar of ronit051397
ronit051397

asked on

Arrays in Pascal

A is an array of Boolean values.
Is there a way to write something like:  A:=False;
instead of writing:    for I:=1 to 10 do  A[I]:=False;
Avatar of williams2
williams2

Nope! ..I don't think so, but otherwise it would look very ugly, and not necessaryly be much faster either.

An alternative would be

Function getBoolArray(BitArray: Integer; index: 0..31): Boolean;
Begin
  Result:= (BitArray Shr index) AND $1 = 1;
End;

Procedure ResetArray(var BitArray: Integer);
Begin BitArray:= 0 end;

I think by chance you should increase points in the future. You can buy them if you don't want to earn them.
Yes, of course, FillChar...
Is there way to define in Pascal like in C:  X:=Y:=Z:=2;  ?
Avatar of ronit051397

ASKER

Depends on your needs. If you want 3 variables that ALWAYS share the same value it works with the adress operator '@'.
If the variables are members of a structure and declared next to each other, use FillChar.
Otherwise, nope.

Slash/d003303
ASKER CERTIFIED SOLUTION
Avatar of d003303
d003303

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial