473,396 Members | 1,599 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,396 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 3090
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.