Solved

Arrays in Pascal

Posted on 1998-03-18
4
177 Views
Last Modified: 2010-04-06
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
Comment
Question by:ronit051397
  • 2
4 Comments
 
LVL 3

Expert Comment

by:williams2
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

by:d003303
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

by:ronit051397
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

by:
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now