Chris, a good technique to trace errors like this is to simply use a pencil & paper and manually follow the instructions in your code. Set & change the values of your variables as you work through the code and your errors should become apparent. Later you will no doubt learn to use the debugger instead of pencil & paper.

There are numerous style issues (indenting, variable naming, layout, comments ...) that could be improved in your code, and 2 main errors.
The first error, as pointed out by ddanbe, is that you only need to calculate 1 average, not 10. The code he suggests will get around that problem. Then when you make that change to a single average you will need to change your comparisons and you may end up with something like this:

``````        for i:=1 to 10 do
if (average<pin[i]) then
min_pl:=min_pl+1
else if (average>pin[i]) then
max_pl:=max_pl+1;``````

This shows that your comparisons are the wrong way around, so your max_pl and min_pl values will be swapped. Better to use:

`````` if (pin[i] < average) then
min_pl:=min_pl+1
else if (pin[i] > average) then
max_pl:=max_pl+1;``````

There is no in-built way to do it so you have to roll your own. There are 2 sides to this problem:
To get the data as booleans rather than dates you could probably use `Calculated fields`.
To display the data using checkboxes take a look at http://delphi.about.com/od/delphitips2009/qt/dbgrid-checkbox.htm

The Welsh, being inventive people, don't need guns to perform mass murders: 5 killed by fire in Prestatyn

That is of course unusual and I don't mean to suggest that mass murder - or murder generally - is commonplace in Wales, but I am not convinced that lack of guns has too much to do with it. For example I suspect that access to guns in Wales is similar to access to guns in Scotland, but Scotland's homicide rate is 2.33 deaths for every 100,000 people each year, compared with 0.7 in England and Wales, giving Scotland the second highest murder rate in western Europe (behind Finland). This suggests to me that if people want to kill each other they will do so, with or without guns, so banning guns may not do much to improve the murder rate. What it would surely do is eliminate a significant cause of accidental death & injury.

If all you want to do is to launch the app then the easiest way is not to find it at all. Just lauch the EXE without specifying its path (for example, Notepad.exe rather than c:\blah\blah\blah\Notepad.exe) and let the OS find it for you. If the EXE is in your path this should work and is worth a try to avoid a possible delay whilst you search for the exe.

If you do have to search for the EXE just remember that an EXE is just a file so you could to use FindFirst and FindNext to locate it. There are many examples out there. A reasonable place to start is http://stackoverflow.com/questions/5991040/how-to-search-different-file-types-using-findfirst

Good that you have something working! That puts you ahead of the game already.

1. Data encapsulation is an important part of OOP.
You have many variables created in the interface var section. Only the hangman variable (the form) needs to be there. The rest all relate to a single instance of the form so can be moved to be part of the form.

2. You leak memory when you create objects.
When you create an object on-the-fly like this:

wordANDdefinition := tStringList.Create;

You allocate memory for that object. (This hapends behind the scenes). You are responsible for releasing that memory when you no longer need it, so somewhere you need a corresponding line like this:

``wordANDdefinition.Free;``

An exception to this is when you create a component and specify an Owner (not nil). In this case the Owner will free the component you created when it (the owner) is freed. You can still free your component if you decide earlier that you don't need it any more but it is OK to leave that job for the owner.

I suggest you add a line in your project source (.dpr file):

``````begin
ReportMemoryLeaksOnShutdown := TRUE; <<< Add line.
Application.Initialize;

When your program closes you will then be informed of any memory leaks.

1. You are on the right lines with your proposed word object.
I suggest you define properties for all the data in the word object. (Don't ...

There is a nice Marquee component at http://www.delphiarea.com/products/delphi-components/marquee/
It can scroll left or write. All you would need to do is handle its onWrap event and swap its direction, like this:

``````procedure TMainForm.MarqueeWrap(Sender: TObject);
begin
if Marquee.BiDiMode = bdLeftToRight then
Marquee.BiDiMode := bdRightToLeft
else
Marquee.BiDiMode := bdLeftToRight;
Marquee.Reset;
end;``````

The component is really nice because you can scroll HTML text & images so it can look much better than a label.

You want a de-compiler rather than a disassembler. I have seen a few mentioned over the years but have never tried them so can't comment on how good they might be. Google should be able to find them. You could start with:

Your bookings record tells you who the booking is for but doesn't tell you what was booked. You need to have another table to cross-reference each booking with the rooms booked. Personally I would put the booking dates into that cross-reference table, so that you can more easily cope with the odd booking which is for 2 rooms on 2 nights and 3 rooms on the third night.

To select unoccupied rooms you could then select all rooms from the room table which have no record in this new cross-reference table for the date(s) of interest.

Why do you need roomID? Each room already has a room number (or possibly room name) which uniquely identifies it, so why do you also need a room ID?

Is an integer the best choice of data type for a phone number? There are 2 potential problems. First, how do you know if a number requires a leading zero, or multiple leading zeroes? (How do you get an international line from that location? Form here it would be prefixed with 00). Second, what if the phone number is given as Nowhereville 30601? You might need alpha characters.

You have a fixed price for each room. How are you going to cope with price rises? How will you know what the price was at the time the booking was made? How will you cope with different prices for off-season or peak? Discounts for regular customers or companies?

A friend of mine did a hotel booking ...

Start a new project.
Add a status bar and set SimplePanel TRUE.
Add a TWebBrowser (and set Align alClient).
Add this for the form's onCreate event handler:

``````procedure TForm2.FormCreate(Sender: TObject);
begin
Application.OnMessage := MyMessages;
wb1.Navigate('https://www.google.com/');  // Or whatever site you want
end;``````

Add a private procedure to the form:

``procedure MyMessages(var Msg: TMsg; var Handled: Boolean);``

Implement that procedure like this:

``````procedure TForm2.MyMessages(var Msg: TMsg; var Handled: Boolean);
var
X, Y: Integer;
document,
E: OleVariant;
begin
if (Msg.message = WM_LBUTTONDOWN) and IsDialogMessage(wb1.Handle, Msg) then
begin
X := LOWORD(Msg.lParam);
Y := HIWORD(Msg.lParam);
document := wb1.Document;
E := document.elementFromPoint(X, Y);
sbar1.SimpleText := 'You clicked on:' + E.outerHTML;
end;
Handled := False;
end;``````

Run the app and click on a button; the status bar shows something like:

``'You clicked on: <input name="btnI" aria-label="I'm Feeling Lucky" type="submit" value="I'm Feeling Lucky" jsaction="sf.lck">'``

You could check that text and call whatever routine you like based on the content.

Oh, and if you don't want the web page to react to the click in the normal way (so clicking the button only runs your procedure without actually clicking the button) you should set Handled to TRUE.

Check if your development environment includes a profiler. You can get a lot of information from a decent profiler. This will help you identify bottlenecks and the profiler will take care of the timing issues for you.

The Netherlands is the largest per CAPITA consumer of cofee averaging 2.4 cups of coffee per person per day.

The annual per capita consumption of coffee in Finland is 9.6 kg dry weight compared to 6.7 kg in The Netherlands (and 3.1 kg in the USA). Source: http://www.caffeineinformer.com/caffeine-what-the-world-drinks
The Netherlands have more cups of coffee per capita because they make such weak coffee.

The Loan Arranger.
You could use the Finance icon supplied with Delphi. Not very nice & just a pile of coins, but at least you have it already.

Mya:) commented: thank you +2

Can you use the MyRoomQuery.AfterUpdateExecute event? Put the if ... then goto ... code in a handler for that event?

Simon, that is a nice and simple approach, better in many ways than changing the event handler. I should have seen that but I focused too much on Michaël's syntax errors rather than his logic. Good catch anyway.

One trivial issue with this code is that the TMediaPlayer already keeps track of what it is doing so you could check MP1.Mode and eliminate the isPlaying variable.

The next tricky issue is the requirement to hold down the mouse to play and release it to pause. The problem here is how to distinguish between a press/hold/release sequence and a click. Taking the view that "holding down" implies some time period longer than a click, I would add a timer and set its interval to, say, 500 and its enabled property false. Add an onMouseDown event handler to enable the timer and in the timer event start the play. In the PlayMedia method disable the timer. The code would be simple:

``````// New method
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X,
Y: Integer);
begin
if not isPlaying then
HoldDownTimer.Enabled := TRUE;
end;

// New method
procedure TForm1.HoldDownTimerTimer(Sender: TObject);
begin
PlayMedia;
end;

procedure TForm1.PlayMedia;
begin
HoldDownTimer.Enabled := FALSE;    <<<=== New line
MP1.Play;
IsPlaying := True;
end;``````

Michaël, if you use this approach to the hold/release requirement, make sure you understand why this code handles mouse down events to start the play but doesn't need to handle mouse up events to pause.

Try this:

``````function NormalizeString(NormForm: Integer; lpSrcString: LPCWSTR; cwSrcLength: Integer;
lpDstString: LPWSTR; cwDstLength: Integer): Integer; stdcall; external 'C:\WINDOWS\system32\normaliz.dll';
function NormalizeText(Str: string): string;
var
nLength: integer;
c: char;
i: integer;
temp: string;
CatStr:string;
begin
nLength := NormalizeString(NormalizationD, PChar(Str), Length(Str), nil, 0); // New line
SetLength(temp, nLength);  // Modified line

nLength := NormalizeString(NormalizationD, PChar(Str), Length(Str), PChar(temp), nLength); // Modified line
SetLength(temp, nLength);  // New line

CatStr:='';
for i := 1 to length(temp) do
begin
c:=temp[i];
if (TCharacter.GetUnicodeCategory(c) <> TUnicodeCategory.ucNonSpacingMark) and // Modified line
(TCharacter.GetUnicodeCategory(c) <> TUnicodeCategory.ucCombiningMark) then
CatStr:=CatStr+c;
end;
result:=CatStr;
end;``````

The terms Local and Global are, to my mind, out of date. Classifying variables as one or the other really relates to the way software used to be written, with a very simple structure. There are more levels now which don't have nice tidy names. To generalise, you need to consider what is called the scope of a variable, which means from where it can be accessed.

A traditional Local variable, as ddanbe says, was declared in a procedure (or function). In Pascal/Delphi it would be something like:

``````procedure DoSomething;
var
MyLocalVariable : integer;
AnotherLocal : string;
begin
{Only code here could use these local variables}
end;``````

These are Local variables, and they can only be used within the DoSomething procedure. We say their scope is the DoSomething procedure. Any value stored in them is lost when DoSomething is complete. When that happens we say they they go out of scope, or are no longer in scope.

A traditional Global variable would be declared outside of a procedure like this:

``````program Project2;

var
MyGlobal : integer;

function Func1 : integer;
var
MyLocal2 : string;
begin
{Code in Func1 can use MyLocal2 and MyGlobal}
end;

procedure Proc1;
var
MyLocal1 : string;
begin
{Code in Proc1 can use MyLocal1 and MyGlobal. It can call Func1.}
end;

begin
{ Code in main program can use MyGlobal, and call Proc1 and Func1 }
end.``````

Here MyGlobal is a Global variable. It is always in scope and it can be used from any code.

That ...

ddanbe commented: Nice explanation. +15
JamesCherrill commented: Excellent discussion +15

I think you'll need to have some software running on the machine which physically has the serial port. You could write that software yourself, or buy it (eg http://www.advancedvirtualcomport.com/index.html).

You want a language that "would be able to do mostly whatever I would like with it" but that is the key question. What do you want to do with it? The most suitable language for you might well depend on whether you want to write desktop software or web stuff or whatever. Also the operating system(s) you will target can also affect your choice.

It is like asking what vehicle should you learn to use. A haulier might pick a truck and a courier might pick a motorcycle.

On the basis that you are "searching for a language that will help me with my career" I guess the real considerations are financial, not technical. Search on a job site covering your area and see which languages are in the most demand.

ddanbe commented: Again: good advice! +15

Aha! Spotted it. Partly dumb code by whoever wrote the web page and partly my own blindness. There IS a difference between the new location and the original URL. The original was:
https://www.somewhere.com/something
and the new location is:
https://www.somewhere.com/something/
So the original author had omitted the trailing backslash. Anyway I am happy now that I understand what is happening, even though it is something stupid.

Rather than regularly rebuilding the list, can you maintain it? Every time a new user appears add him/her to your list, and remove them from your list when they go away?

Well ultimately it must be possible, but you need more information before you can see how difficult it might be and what might be involved.
The most important consideration is what type of database is in use. Legacy systems such as this may use a proprietary/in-house design, or an outdated technology, which requires more work to access.

The other question is why choose vb.net? Since you have existing Pascal code a more logical choice might be Delphi or a current Pascal compiler such as Free Pascal. This might cut down the work needed.

zainab_8271 commented: thnx for the reply i really appreciate it , they use mostly COBOL and the database is DB2 , so is it possible to make a GUI for it? +0

What is dmProgramDatabase? My guess is that it is a data module and you have not created it before InitDBGrid is called.

I suppose one approach for people who don't/won't use a "computer" is to enhance devices that they do/will use. As an example, my mother does not have nor want a computer, but she does use features on her (landline) phone for caller ID, number storage & searches, call logs and so on. If landline phones were enhanced with more of the features found on smart mobiles, she might increase her usage of more advanced features and might eventually turn to the internet (if presented in a less "computer" style). An obvious route in to that would be if she could search yellow pages right there on her phone, and from there it would be a small step to general google-type search facilities.

For other people/cultures it might be a different device that gets them started, but the principle would be the same. Gradually add features to familiar devices and converge interfaces so that familiarity with one device helps people to use more devices. Exactly what device you start with would depend upon what devices are used or would be acceptable to the target culture.

Actually I am not sure if you can buy Delphi 8 these days. It was released in 2003. If memory serves, this version was just for .NET and was a bit of a lame duck. I would surprised if anyone could or would sell it now.

That is one way. (There are of course other ways.)

Why do you say this is too big coding? Too much typing? Too much to understand? Requires too much memory? In reality it is a tiny program.

If you just think it is too much code to type or read, you could trim it down quite easily. For example:

``````if gamemode=1 then                                                                   {If gamemode 1 has been chosen}
begin
clrscr;
title;
writeln ('Welcome to Calculator');
writeln;
writeln ('To begin, press <Enter>');
clrscr;
title;
writeln ('Choose which symbol is needed');
writeln ('"+" "-" "*" "/"');
clrscr;
title;
writeln ('Addition Problem (One time use only)')
else if symbol='-' then      {subtraction}
writeln ('Subtraction Problem (One time use only)');
else if symbol='*' then      {multiplication}
writeln ('Multiplication Problem (One time use only)');
else if symbol='/' then     {division}
writeln ('Division Problem (One time use only)');
writeln;
writeln ('Enter two numbers(with spaces) to solve out.(No decimal numbers)');
CalcResult := Val1 + Val2
else if symbol='-' then      {subtraction}
CalcResult := Val1 - Val2
else if symbol='*' then      {multiplication}
CalcResult := Val1 * Val2
else if symbol='/' then     {division}
CalcResult := Val1 / Val2;
writeln;
writeln ('The result is ',CalcResult);
clrscr;
title;
quit;
end.``````
``````    else if(n < k && k < m)
{
cout << m << endl;
cout << k << endl;
cout << n << endl;
}``````

At least this output is wrong for the specified values, but I don't think this is the only error.

With code like this (or any code really) it is much easier to spot errors if you step through line by line in the debugger.

Also consider what happens if any of the input values are equal.

Why do you test the number to see if it is odd and then test to see if it is even? If it isn't odd it must be even, no?

For a simple test for whether a number is prime, see: http://www.nickhodges.com/category/Delphi.aspx?page=4

Not really exporting; you don't necessarily have to do anything in Access. So I guess it is more like importing your Access data into Excel.

Try it:
In Excel, open a file.
A file selection dialog appears.
Change the file type to "Access Databases".
Select the Access database you want.
You may get a security warning. Click Enable.
A "Select Table" dialog appears. This lists available tables and queries.
Select the one you want & click OK.
The Access data is then displayed in Excel.

If you want to you can write a query in Access to provide just the data you require and then open that query in Excel.

Stuugie commented: Exactly right! +5

Sorry, I don't have a C++ development environment installed to check this, but shouldn't you clear the childcontrols vector before you call EnumChildWindows? Also, do you need to maintain your own count in controlscount? Can't you use childcontrols.size directly?

Should the order of these 2 lines be reversed?

``````    cc->childcontrolsindex = cc->childcontrols.size(); // TODO:
cc->controlscount=i;``````

With these lines in the current order, after you add the first child window handle controlscount is 0 rather than 1.

cambalinho commented: thanks for that tip +0

EnumChildWindows() isn't correct with 3rd and 4th arguments :(
I find this comment a little confusing because EnumChildWindows takes only 3 parameters, not 4.

The first parameter in your call to EnumChildWindows is the handle of the parent window.

The second parameter in your call to EnumChildWindows is a pointer to a callback function that will be called once for every child window (unless you bail out early, see below). I think that callback function should be a simple function, not a class method. So you should write your code in a function that is not part of your class. This function will receive (must accept) 2 parameters: the handle for the child window and a value that you specify when you call EnumChildWindows.
If your callback function returns TRUE then it will continue to be called for more child windows. If it returns FALSE then enumeration will stop and the callback function will not be called for any remaining child windows.

The third parameter in your call to EnumChildWindows is a value that will be passed as the 2nd parameter in each call to the callback function. Typically this parameter will hold a pointer to some data to be used by the callback function, so you can effectively pass anything you like really. In your case you might pass a pointer to the ChildControls instance calling EnumChildWindows, and simply have the callback function add its 1st parameter to a list of child window handles held by that instance. ...

cambalinho commented: thanks for all +2