im making a game in delhi n its a hangman game n it all works but my letters dont appear in place of my question marks. can anyone look at my code for n see wat is wrong wit. ps i have the code behind each letter for the alphabet.
here is the code:

procedure TEasyForm.ABtnClick(Sender: TObject);
begin
      ABtn.Enabled:= false;          {When ABtn is clicked the button is disabled}
      key:= 'A';
      found:= false;          //Check if the letter the user pressed is in the Computer Word
      for count:= 1 to NumberOfLetters do
      if ComputerWord[count] = key then
        begin                   // the letter the user pressed is in the Computer Word
          found:= true;
          UsersWord[count]:='A';
          NumberFound:= NumberFound + 1;
        end;
      if found        // update label on form
        then
          begin
            wordLbl.Caption:='';
            for count:= 1 to length(UsersWord) do
              WordLbl.Caption:=wordLbl.Caption + UsersWord[count] + ' ';
          end
      else
      begin
        NumberOfErrors:= NumberOfErrors + 1;  // else increase the number of errors
       Image1.Picture.LoadFromFile('imageeasy' + IntToStr (NumberOfErrors) + '.bmp');
      end;
      if NumberFound = NumberOfLetters        // the user quessed the word
        then ShowMessage('YAY! YOU WIN[IMG]http://www.delphipages.com/smilies/Exclamation.gif[/IMG]
          else if NumberOfErrors = 6
            then showMessage ('YOU LOSE! THE WORD WAS ' + ComputerWord);
      end;

The code works properly. The letter 'A' appears. Maybe you forgot to initiate UsersWord:=' '. But for UsersWord it is better to use the char array.
UsersWord:array[1..n] of char.

hey how do i initiate the users word is simply:

UsersWord:= '';

or is there something more because i still cannot make it work still
plz help

Just as a suggestion. I wouldn´t place a function to every Button with a Character. Instead i would use a single Function for all of the letter-buttons. You could place the character that the button represents into the hint of the appropriate Button like:

Button.Hint := 'A';

Now in the function you have to decide which Button has evoked the function. For Example:

procedure TEasyForm.BtnClick(Sender: TObject); // Sender is the Button that evoked the functon
begin
  // If you´ve used a Delphi TButton-Class you can cast like this
  TButton(Sender).Enabled:=false; 
  key := TButton(Sender).Hint;
  ...
 
// If you´ve used some other Component you have to use
  TSomeOtherButtonClass(Sender).Enabled := false;
  key := TSomeOtherButtonClass(Sender).Hint;
  ...

Now you have only one function for all the buttons to deal with :-)
greetings
Nostromo

hey how do i initiate the users word is simply:

UsersWord:= '';

or is there something more because i still cannot make it work still
plz help

I mean this:
UsersWord:= '_____'; where '_' is a space symbol
because if UsersWord containes '' then UsersWord will rase an error.
And why don't you use array of char?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.