Solved

# Arrays in Pascal

Posted on 1998-03-18
177 Views
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;
0
Question by:ronit051397
• 2

LVL 3

Expert Comment

ID: 1360583
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.
0

LVL 4

Expert Comment

ID: 1360584
Yes, of course, FillChar...
Is there way to define in Pascal like in C:  X:=Y:=Z:=2;  ?
0

LVL 5

Author Comment

ID: 1360585
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
0

LVL 4

Accepted Solution

d003303 earned 20 total points
ID: 1360586
or quite simply (and standard-following)...you can do

PROCEDURE resetArray(a: ARRAY OF BOOLEAN);
VAR i: INTEGER;
BEGIN
FOR i:= low(a) TO high(a) DO a[i]:=FALSE
END;
0

## Featured Post

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.