Atozed Forums
How do I set values in a form before it is displayed (opened)? - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: How do I set values in a form before it is displayed (opened)? (/thread-2217.html)



How do I set values in a form before it is displayed (opened)? - Сергей Александрович - 01-03-2021

Мне нужно установить некоторые значения в полях редактирования, прежде чем показывать форму. Я делаю это:

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

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

Как это сделать правильно?


RE: How do I set values in a form before it is displayed (opened)? - kudzu - 01-03-2021

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;


RE: How do I set values in a form before it is displayed (opened)? - Сергей Александрович - 01-03-2021

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'


RE: How do I set values in a form before it is displayed (opened)? - kudzu - 01-03-2021

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;


RE: How do I set values in a form before it is displayed (opened)? - kudzu - 01-04-2021

TfmSendMailWEB.Create(Self)

should be:

TfmSendMailWEB.Create(WebApplication)

as well


RE: How do I set values in a form before it is displayed (opened)? - Сергей Александрович - 01-05-2021

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.


RE: How do I set values in a form before it is displayed (opened)? - kudzu - 01-05-2021

Thanks for the background info, its helpful. Many of us here (including me) are self taught developers.


RE: How do I set values in a form before it is displayed (opened)? - Сергей Александрович - 01-06-2021

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.