Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I set values in a form before it is displayed (opened)?
#1
Мне нужно установить некоторые значения в полях редактирования, прежде чем показывать форму. Я делаю это:

TfmWEB.Create (Self);
TfmWEB. edEmail.Текст := 'mail@mail.ru';
TfmWEB. edThema.Текст : = ' MyThema';
TfmWEB. Show;

Компилятор возвращает ошибку:
[ошибка dcc32] unAuth. pas (60): ожидаемый идентификатор метода E2096

Как это сделать правильно?
Reply
#2
Im not sure if pasting altered the source but your whitespacing is wrong. Also next time please specify exactly which line is the problem as the IDE will tell you. This is an issue with Delphi syntax, not IntraWeb.

Proper spacing is below:

TfmWEB.Create (Self);
TfmWEB.edEmail.Текст := 'mail@mail.ru';
TfmWEB.edThema.Текст := 'MyThema';
TfmWEB.Show;
Reply
#3
Compilation error on line 60 characters

59 TfmSendMailWEB.Create(Self);
60 TfmSendMailWEB.edEmail.Text := 'mail@mail.ru';
61 TfmSendMailWEB.Show;

[dcc32 Error] unAuth.pas(60): E2096 Method identifier expected
[dcc32 Error] unAuth.pas(61): E2076 This form of method call only allowed for class methods or constructor
[dcc32 Fatal Error] F2063 Could not compile used unit 'unAuth.pas'
Reply
#4
TfmSendMailWEB is the class name, not the instance. You need to store the instance from Create.

Are you new to Delphi?

var
xPage: TfmSendMailWEB;
begin
xPage := TfmSendMailWEB.Create(Self);
xPage.edEmail.Text := 'mail@mail.ru';
xPage.Show;
Reply
#5
TfmSendMailWEB.Create(Self)

should be:

TfmSendMailWEB.Create(WebApplication)

as well
Reply
#6
Thanks for the answer. Now everything works. I'm not new to Delphi, but my knowledge of Delphi is very specific...
I'm a radio engineer by training, of course, I studied programming as part of the educational process... then it was the ALGOL language. Later, when I was already working, I became interested in programming and independently studied FORTRAN, programmed a little in MNEMONIC CODE( assembler), then CLIPPER.
Around 2000, he started writing in Delphi.
All my language learning takes place as needed. That is, it happens something like this: There is some kind of task, for its implementation it is necessary to solve certain technical issues and I study exactly what I need for this. It turns out quite effectively. Well, with a similar situation, with a question on which I have simply not encountered for all the years.... Surprisingly, but a fact. You helped me take another step in learning Delphi. Thank you again.
Reply
#7
Thanks for the background info, its helpful. Many of us here (including me) are self taught developers.
Reply
#8
OH, YES ! The most talented programmer in the company Energia, at the time when we worked together, was a mechanical engineer by training. When I worked as the head of the plant's automated control system department, one of the best programmers was a physics engineer by training. One of my programmers was a helicopter pilot by training... So it seems that this is not the exception, but the rule ! In general, programming is probably not a specialty, it is a state of mind.

I apologize for the digression.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)