Solved

Arrays in Pascal

Posted on 1998-03-18
4
180 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

776 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