Good day, i am getting an error from this piece of code, can you please assist. Error says "Number of element differs from declarations "
Your assistance will be appreciated. thank you
here is the code:
unit Unit1;
interface
type
TUnit1 = record
ServerName :char;
ServerPort :integer;
ActiveFlag :boolean;
end;
const
Servers : array[boolean] of string =
('inf1', 'inf_15','inf_18',
'inf_22', 'inf_21', 'inf_20',
'inf_23', 'inf_26', 'inf_25', 'inf_24');
3 3086
If you want to index an array with a boolean type the array can have only two elements: one element for the 'false' index value and one for 'true'. You try to initialize it with ten elements; that's what the compiler is whining about.
kind regards,
Jos (<--- knows zilch about Delphi)
Thank you for your response. I actually found a solution to my problem. it should be as follows:
type
TUnit1 = record
ServerName :string;
ServerPort :integer;
ActiveFlag :boolean;
end;
const
Servers : array[0..9] of TUnit1 =
((ServerName :'inf1', ServerPort :125, ActiveFlag :false); (ServerName :'inf_15',ServerPort :125, ActiveFlag :false); (ServerName :'inf_18',ServerPort :125, ActiveFlag :false);
(ServerName :'inf_22', ServerPort :125, ActiveFlag :false); (ServerName :'inf_21',ServerPort :125, ActiveFlag :false); (ServerName :'inf_20',ServerPort :125, ActiveFlag :false);
(ServerName :'inf_23',ServerPort :125, ActiveFlag :false); (ServerName :'inf_26',ServerPort :125, ActiveFlag :false); (ServerName :'inf_25',ServerPort :125, ActiveFlag :false); (ServerName :'inf_24',ServerPort :125, ActiveFlag :false) );
That makes sense: now you're indexing your array with an integer range 0 ... 9; you also changed the type of your array elements. Good luck.
kind regards,
Jos
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Erva |
last post by:
Hi,
Is there someone who has moved from Delphi to VS.NET?
I'am using Delphi currently but seriously considering to moving VS.NET. I
would like to hear if someone has already done that, is it...
|
by: sarah18web |
last post by:
Hello,
the following problem:
I use Delphi 6 to access a MS Access Database.
In short, the Delphi Code looks like this:
ADOConnection1.Open;
ADOQuery1.Close;
ADOQuery1.SQL.Text := 'SELECT...
|
by: Tim Conner |
last post by:
Hi,
I am an ex-delphi programmer, and I having a real hard time with the
following simple code (example ):
Which is the equivalent to the following code ?
var
chars : PChar;
sBack, s :...
|
by: NathanV |
last post by:
Anyone familiar with Delphi know of a similar type to the TStringList in C#?
Thanks,
Nathan
|
by: Mel Weaver |
last post by:
Hello,
I looking for different ideas on how to convert this delphi code to c#,
mostly the constant array.
procedure PhysDmgSymbol(sym : string; yr: integer);
type
d = record
s : String;
r :...
|
by: Sonnich |
last post by:
Hi
Is the such a function like IN in delphi:
if( $somechar in )
dsafsakjldg;
where true is for the characters mentioned above.
BR
|
by: Megabeans |
last post by:
Hi
Im trying to get my vb program to talk to a Delphi written dll. I can get it to work as long as I only ask for the first char in a string but I cant seem to return the whole string from the dll...
|
by: TeeJee |
last post by:
Hi,
I have to pass an array by ref to a referenced Delphi Com dll, but all my attempts end in an error.
I'm using VS2003 and I referenced the com dll in my project with 'add reference'.
The...
|
by: kelvin.koogan |
last post by:
How can I call a function in a Delphi DLL from C++/CLI?
The Delphi function is declared as follows:
function Func1(IsDsb: Boolean; FirstStr, SecondStr : String): String;
I've tried
...
|
by: BornTOCode |
last post by:
Hello,
I am attempting to call a (Delphi) win32 DLL from a Delphi.Net webservice. I am using a slightly modified version of the hello world webservice that comes with Delphi 2006.
The DLL...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |