S
S
Suleymanov2020-09-10 19:31:26
Pascal
Suleymanov, 2020-09-10 19:31:26

How to determine the type of a variable?

program Color;
uses crt;
const
  ColorCount = 16;
var
  AllColors: array [1..ColorCount] of word = 
  (
    Black, Blue, Green, Cyan,
    Red, Magenta, Brown, LightGray,
    DarkGray, LightBlue, LightGreen, LightCyan,
    LightRed, LightMagenta, Yellow, White
  );
;

procedure makeline(line, fgcolor: integer);

MakeLine(i, Allcolors[i mod ColorCount + 1]);


I recently started learning Pascal and can't find the answer anywhere. Why when we declare an array with variables of type WORD , and when we access a specific array variable. We can use it as an INTEGER variable for a procedure. And what is Allcolors[i] ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
HemulGM, 2020-09-10
@ms-config

Because not explicit type conversion works. You can also use Integer if you need float or double. Or type char if a string is required.
This is possible because the range of word values ​​is within the range of Integer values. A character can also be a string.
Allcolors[i] is the i (th) element of the array. In this case, an element of type word. Or rather - the color for the console.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question