Recent

Author Topic: I just wanted to ask a simple question...  (Read 730 times)

nightrider43

  • Newbie
  • Posts: 4
I just wanted to ask a simple question...
« on: November 01, 2024, 12:52:26 am »
I have already consulted charGPT, Gemini, Meta AI and Lazarus Wiki. I can't get rid of the compilation error of the MessageDlg command in the code below. I beg for someone's help. What a complex thing. I just want to ask YES or NO with the default NO.
Code below:
procedure TfrmGeraString.btnGoMainClick(Sender: TObject);
  var resposta : integer;
  begin
    if Length (tedtNomArqMic.Text) = 0 then
       begin;
         ShowMessage ('Informe nome do arquivo no microcomputador');
         Exit;
       end
    else
       if Length (cbxNomArqMain.Text) = 0 then
          begin;
            ShowMessage ('Informe nome do arquivo do mainframe');
            Exit;
          end
       else
          if (Pos('(',cbxNomArqMain.Text) <> 0) and (Pos(')',cbxNomArqMain.Text) = 0) or
             (Pos('(',cbxNomArqMain.Text) = 0) and (Pos(')',cbxNomArqMain.Text) <> 0) then
             begin;
               ShowMessage ('Parênteses do nome do arquivo do mainframe mal colocados');
               cbxNomArqMain.SetFocus;
               Exit;
             end
          else
             begin;
               nomarqmic := ExtractFileName (tedtNomArqMic.Text);
               if (Length (nomarqmic) <> 0) and (Pos (nomarqmic,cbxNomArqMain.Text) = 0) then
                     begin;
                       ShowMessage ('Alerta: O nome do arquivo do micro não ' +
                                   'aparece no nome do arquivo do mainframe');
                       resposta = MessageDlg ('Confirma:','Continuar o processamento?',mtConfirmation,[mbYes, mbNo],0);
                       if resposta = mrNo then
                          cbxNomArqMain.SetFocus;
                     end;
               MontaString (tedtNomArqMic.Text,cbxNomArqMain.Text,rbTransMicro.Checked);
               ShowMessage('Clique Fim para gravar o arquivo com o string de transmissão ou selecione um radio button para gerar outro comando de transmissão');
               tedtNomArqMic.Clear;
               cbxNomArqMain.Text := '';
             end;
  end;

Greetings from São Paulo - Brazil

Arí Ricardo Ody
« Last Edit: November 02, 2024, 10:18:16 pm by marcov »

Fibonacci

  • Hero Member
  • *****
  • Posts: 594
  • Internal Error Hunter
Re: I just wanted to ask a simple question...
« Reply #1 on: November 01, 2024, 12:57:25 am »
Code: Pascal  [Select][+][-]
  1. resposta = MessageDlg

Change to

Code: Pascal  [Select][+][-]
  1. resposta := MessageDlg



Code: Pascal  [Select][+][-]
  1. procedure TfrmGeraString.btnGoMainClick(Sender: TObject);
  2. var
  3.   resposta: integer;
  4. begin
  5.   if Length(tedtNomArqMic.Text) = 0 then begin
  6.     ShowMessage('Informe nome do arquivo no microcomputador');
  7.     Exit;
  8.   end else if Length(cbxNomArqMain.Text) = 0 then begin
  9.     ShowMessage('Informe nome do arquivo do mainframe');
  10.     Exit;
  11.   end else if (Pos('(', cbxNomArqMain.Text) <> 0) and (Pos(')', cbxNomArqMain.Text) = 0) or
  12.     (Pos('(', cbxNomArqMain.Text) = 0) and (Pos(')', cbxNomArqMain.Text) <> 0) then begin
  13.     ShowMessage('Parênteses do nome do arquivo do mainframe mal colocados');
  14.     cbxNomArqMain.SetFocus;
  15.     Exit;
  16.   end else begin
  17.     nomarqmic := ExtractFileName(tedtNomArqMic.Text);
  18.     if (Length(nomarqmic) <> 0) and (Pos(nomarqmic, cbxNomArqMain.Text) = 0) then begin
  19.       ShowMessage('Alerta: O nome do arquivo do micro não ' +
  20.         'aparece no nome do arquivo do mainframe');
  21.       resposta := MessageDlg('Confirma:', 'Continuar o processamento?', mtConfirmation, [mbYes, mbNo], 0);
  22.       if resposta = mrNo then cbxNomArqMain.SetFocus;
  23.     end;
  24.     MontaString(tedtNomArqMic.Text, cbxNomArqMain.Text, rbTransMicro.Checked);
  25.     ShowMessage('Clique Fim para gravar o arquivo com o string de transmissão ou selecione um radio button para gerar outro comando de transmissão');
  26.     tedtNomArqMic.Clear;
  27.     cbxNomArqMain.Text := '';
  28.   end;
  29. end;
« Last Edit: November 01, 2024, 01:00:52 am by Fibonacci »

egsuh

  • Hero Member
  • *****
  • Posts: 1488
Re: I just wanted to ask a simple question...
« Reply #2 on: November 01, 2024, 11:24:15 am »
If you are using Exit, you don't have to add else after that. But not sure in readability. If you insist using "else" then you don't have to put Exit.

Code: Pascal  [Select][+][-]
  1. procedure TfrmGeraString.btnGoMainClick(Sender: TObject);
  2. var
  3.   resposta: integer;
  4. begin
  5.   if Length(tedtNomArqMic.Text) = 0 then begin
  6.     ShowMessage('Informe nome do arquivo no microcomputador');
  7.     Exit;
  8.   end;
  9.  
  10.   if Length(cbxNomArqMain.Text) = 0 then begin
  11.     ShowMessage('Informe nome do arquivo do mainframe');
  12.     Exit;
  13.   end;
  14.  
  15.   if (Pos('(', cbxNomArqMain.Text) <> 0) and (Pos(')', cbxNomArqMain.Text) = 0) or
  16.     (Pos('(', cbxNomArqMain.Text) = 0) and (Pos(')', cbxNomArqMain.Text) <> 0) then begin
  17.     ShowMessage('Parênteses do nome do arquivo do mainframe mal colocados');
  18.     cbxNomArqMain.SetFocus;
  19.     Exit;
  20.   end;
  21.  
  22.   nomarqmic := ExtractFileName(tedtNomArqMic.Text);
  23.    ....
  24.  
  25. end;

nightrider43

  • Newbie
  • Posts: 4
Re: I just wanted to ask a simple question...
« Reply #3 on: November 02, 2024, 02:10:08 pm »
Hello!

I have no explanation to justify not having noticed the lack of the 2-dot graphic symbol. It was a naive and horrible mistake.

Thank you for your reply.

I am even embarrassed. Thank you once again for your tolerance.

Greetings from São Paulo - Brazil

Arí Ricardo Ody

« Last Edit: November 02, 2024, 10:18:30 pm by marcov »

DavidL

  • New Member
  • *
  • Posts: 13
Re: I just wanted to ask a simple question...
« Reply #4 on: November 02, 2024, 02:33:10 pm »
Hello!

I have no explanation to justify not having noticed the lack of the 2-dot graphic symbol. It was a naive and horrible mistake.

Thank you for your reply.

I am even embarrassed. Thank you once again for your tolerance.

Greetings from São Paulo - Brazil

Arí Ricardo Ody

Don't be so hard on yourself.  It will happen again.  It's a very common mistake that, even after almost 50 years of writing software, I still make.  The C language equivalent is "=" and "==" - that one can drive you nuts for sure.
« Last Edit: November 02, 2024, 10:19:48 pm by marcov »

carl_caulkett

  • Hero Member
  • *****
  • Posts: 649
Re: I just wanted to ask a simple question...
« Reply #5 on: November 02, 2024, 11:54:11 pm »
Hello!

I have no explanation to justify not having noticed the lack of the 2-dot graphic symbol. It was a naive and horrible mistake.

Thank you for your reply.

I am even embarrassed. Thank you once again for your tolerance.

Greetings from São Paulo - Brazil

Arí Ricardo Ody

You might be interested in this code template which allow you to insert a := simply by pressing ;; followed by a space. Code Templates are so cool. You can build up a set of useful little templates which make some incremental improvements to your work flow ;)
 
"It builds... ship it!"

Fibonacci

  • Hero Member
  • *****
  • Posts: 594
  • Internal Error Hunter
Re: I just wanted to ask a simple question...
« Reply #6 on: November 03, 2024, 12:01:52 am »
You might be interested in this code template which allow you to insert a := simply by pressing ;; followed by a space. Code Templates are so cool. You can build up a set of useful little templates which make some incremental improvements to your work flow ;)

Ur Lazarus version?

Code: Text  [Select][+][-]
  1. [Error]
  2.  
  3. The token can only contain Latin letters, numbers and underscores, and cannot begin with a number.
  4.  
  5. [OK]

carl_caulkett

  • Hero Member
  • *****
  • Posts: 649
Re: I just wanted to ask a simple question...
« Reply #7 on: November 03, 2024, 01:49:19 am »
You might be interested in this code template which allow you to insert a := simply by pressing ;; followed by a space. Code Templates are so cool. You can build up a set of useful little templates which make some incremental improvements to your work flow ;)

Ur Lazarus version?

Code: Text  [Select][+][-]
  1. [Error]
  2.  
  3. The token can only contain Latin letters, numbers and underscores, and cannot begin with a number.
  4.  
  5. [OK]

FPC 3.3.1 / Lazarus 3.99, but I'm pretty sure this worked in FPC 3.2 / Lazarus 3.4 as well.
"It builds... ship it!"

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1427
    • Lebeau Software
Re: I just wanted to ask a simple question...
« Reply #8 on: November 03, 2024, 06:31:54 am »
I have no explanation to justify not having noticed the lack of the 2-dot graphic symbol.

The "2-dot symbol" is formally known as a colon.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

 

TinyPortal © 2005-2018