473,320 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Delphi Array

2
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');
Mar 25 '09 #1
3 3086
JosAH
11,448 Expert 8TB
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)
Mar 26 '09 #2
Owam
2
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) );
Mar 26 '09 #3
JosAH
11,448 Expert 8TB
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
Mar 26 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
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...
2
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...
7
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 :...
5
by: NathanV | last post by:
Anyone familiar with Delphi know of a similar type to the TStringList in C#? Thanks, Nathan
2
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 :...
8
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
0
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...
2
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...
5
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 ...
0
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...
0
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...
0
isladogs
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...
1
isladogs
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...
0
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...
0
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...
1
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)...
0
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....
0
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
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.