Archived

This topic is now archived and is closed to further replies.

rodneyldixon

Problems with Delphi Hello World

Recommended Posts

Ok I went and bought this book on Delphi Programming, and its showing how to write a Hello World by putting a button on the form, and typing in the code for it. And I do this by putting a standard button on the form, and then I look in the Object Inspector and I click Events, it then shows me whenclickedon, and I double click in the box on the right side of it, and this is where I type in the code: Label1.Caption := 'Hello World'; I'm using Borland Delphi 5.0 Enterprise Edition IDE. And when I click run, it gives me a bunch of errors. Why?, And how do I fix them? Edited by - rodneyldixon on June 20, 2001 1:29:59 PM

Share this post


Link to post
Share on other sites
I don''t know delphi, so i cannot help you, but here is some advice:

If you want people to help you, you should post more details about your problem, especially which errors you are recieving.

People are hesitant to help someone who asks only vague questions.

Share this post


Link to post
Share on other sites
hehe,

where did you get that label from....

Dunno, should work. Try compiling samples shipped with borland.
If they also don''t work, then you probably have to reinstall orso...

Sounds more like you missing some part of Delphi (the labels duhhh.. )

Gr,
BoRReL

Share this post


Link to post
Share on other sites
OK rodney, you gotta Delphi programmer here, and based on what you''re putting up here, Mulder''s bet is best: you probably didn''t drop the label on the form.

The first question is, of course, what kind of errors you got on compile. After that, make sure you''ve got a label on there named Label1 (which it will name itself by default). It will default to a Caption of ''Label1'' when you run it.

You know what the coolest things about Delphi are? Strings are a datatype and not a class (can''t call string.length() anymore)! Strings have an initial subscript of 1 and not 0!!

And remember, when in doubt, Ctrl+F2 in the IDE resets the program, and is your most special friend!


---------------
-WarMage
...may the happiness hit ya where the good lord split ya...

Share this post


Link to post
Share on other sites
Ok, let me put it in a way that everyone can understand. I''m using Borland Delphi 5.0 Enterprise Edition.

Step 1: I put a button on the form
Step 2: I click it, and then click the Events tab
Step 3: I double click on whenclickedon
Step 4: It brings it up where I can type code for that button
Step 5: I type: Label1.Caption := ''Hello World'';
Step 6: I click run and it gives me the following errors :

Unit.pas(28): Undeclared indentifier: ''Label1''
Unit.pas(33): Declaration expected but end of file found
Project1.dpr(5): Could not compile used unit ''Unit1.pas''

But I can run all the samples that came with it. So how do I fix this problem?

Share this post


Link to post
Share on other sites
like i said
you haven''t defined label1 so you have to drag and drop a label there and call it label1 after that run it and it should work i think (me don''t know delphi )

Share this post


Link to post
Share on other sites
Yep,

as said...
You haven''t defined the label.
So before adding label1.caption := ''blablabla''
first put a label on the form and name it label1 (should be automatic)

You can also test your button by fe say form1.caption := ''blablablab''
Now the tiltebar of your form (which is probably form1) is changed.

Gr,
BoRReL

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:

I''m using Borland Delphi 5.0 Enterprise Edition IDE.



Try re-installing Delphi. If it still doesn''t work, try visiting goatse.cx for more advice.

Good luck.

Share this post


Link to post
Share on other sites
Hey Moderator. It actually seems like Rodney is trying, but a bunch of these people are still making off-posts. I think their posts should be removed because it sounds like he made a simple "DUH" mistake.

Just a thought.


BeS
It''s Da BOMB Baby!!!
. o O ~
A little nonsense now and then,
is relished by the wisest men
~ O o .
-- Willy Wonka

Share this post


Link to post
Share on other sites
Rodney, I''d love to help you but you kep setting yourself up as flamebait. We (royal ''we'' invoked here) don''t want to discourage someone who is interested in programming, but dude, READ YOUR SOURCES AND HELP FILES!!! Delphi has one of THE best help files for a language/IDE.

It was really simple to look in the message window and see that Delphi didn''t knwo what ''Label1'' was. It seems like you''re trying to skip all the early lessons involved with creating visual apps.. learning how to PROPERLY design forms. Obviously you''re just getting started. What I really think you need to do is spend a little more time hunting for the answer with your own resources, and once that fails, come on down and see what the braintrust here has to offer.

I''m not trying to smack you down, just trying to make sure you understand why you might feel like the smackdown has been applied to you.
--------------
-WarMage
...patience is a virtue, and few are indeed virtuous...

Share this post


Link to post
Share on other sites
Rodney, you missed the bit in the book that told you to go to the Component Palette, click on the Standard tab, click on the TLabel button and then click on your form. The same as you did to add the button. The TLabel is a few components to the right in the component palette. This adds a TLabel to your form that by default gets named 'Label1'. Do this and then run your program. You will find that it now works.

If all else fails, go back to the beginning of the chapter and start reading again. Be careful not to miss any words.

For someone who claimed in a previous message to have learnt C, C++ and assembly in a couple of weeks, I would have expected you to have had your PSX, GameCube, PS2, Xbox (and every other console you listed) emulator done by now.

Steve 'Sly' Williams   Code Monkey  Krome Studios

Edited by - Sly on June 21, 2001 6:28:31 PM

Share this post


Link to post
Share on other sites
Ok, the problem was like everyone said, I forgot to put the label on the form. Thanks!

But how can I test my button to when you press it, it will say Hello World?

Share this post


Link to post
Share on other sites
Just like you said yourself in your first post..

- Click/select the button on the form.
- Then click the events tab in the object inspector.
- Then fill out the whenclickedon event (type function name)
- In that function you type: Label1.Caption := "Hello World";

Like others have said a million times..Take the time to read that book properly..Don´t skip anything....
I am 100% sure that this problem could have been solved if you had taken the time to look for it in the book..

READ THE BOOK !!


Edited by - granat on June 22, 2001 2:24:26 AM

Share this post


Link to post
Share on other sites
Where the HELL did you get the Enterprise version?

Now I understand. Maybe he''s spoiled... Used to getting what ever he wants ASAP, and programming is taking too long.

Dunno, just an observation.

Thank you for your bandwidth.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~Succinct Demos Online~
I am a software engineer who writes poetic code!

Share this post


Link to post
Share on other sites
quote:
Original post by Succinct
Where the HELL did you get the Enterprise version?

Now I understand. Maybe he''s spoiled... Used to getting what ever he wants ASAP, and programming is taking too long.

Dunno, just an observation.

Thank you for your bandwidth.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~Succinct Demos Online~
I am a software engineer who writes poetic code!



I ordered the Evalutation CD from the website. And after I finish using it, and I like it, I''m going to buy the full version of it.

Share this post


Link to post
Share on other sites