Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Arrays in Pascal

Posted on 1998-03-18
4
Medium Priority
?
185 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 80 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

824 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