Recent

Author Topic: code check  (Read 3797 times)

scons

  • Full Member
  • ***
  • Posts: 141
code check
« on: February 04, 2016, 08:58:24 pm »
I must forget something here, but I can't figure out what ... tried to add ";" to a few places but it still gives an error.

frm1.pas(103,7) Fatal: Syntax error, ";" expected but "identifier STATUSBAR1" found

Who can teel me what I forget ?

Thanks

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button3Click(Sender: TObject);
  2. var
  3.   sa: string;
  4.   sb: string;
  5.   sc: string;
  6.   myDateTime1 : TDateTime;
  7.   myDateTime2 : TDateTime;
  8.   myDateTime3 : TDateTime;
  9.   oldName, newName: string;
  10.   i, renameCount: integer;
  11.   NameA, nameB : string;
  12. begin
  13.   myDateTime1 := 0;
  14.   myDateTime2 := 42410;
  15.   myDateTime3 := now();
  16.   sc := FormatDateTime('dd.mm.yyyy', myDateTime3);
  17.   if myDateTime3<myDateTime2 then
  18.    begin
  19.     if (ListBox1.Count > 0) then
  20.      begin
  21.       renameCount:=0;
  22.       for i:=0 to ListBox1.Count-1 do
  23.         begin
  24.         if ExtractFileExt(ListBox1.Items[i])=('.txt') then
  25.           begin
  26.             NameA := (extractFilePath(Listbox1.Items[i]));
  27.             NameB := Copy((extractFileName(Listbox1.Items[i])),5,10);
  28.             oldName := ListBox1.Items[i];
  29.             newName := (NameA) + (Edit1.Text) + (NameB);
  30.             if RenameFileUTF8(oldName, newName) then
  31.                Inc(renameCount);
  32.           end
  33.         end
  34.       StatusBar1.SimpleText:=Format('  %d files renamed',[renameCount]);
  35.      end
  36.   else
  37.    begin
  38.      sleep(200);
  39.      ShowMessage('You waited too long' + sLineBreak + 'Expired at ' + sc);
  40.      sleep(200);
  41.      Close;
  42.    end;
  43. end;
Windows 10-64bit Lazarus 3.2 + FPC 3.2.2

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: code check
« Reply #1 on: February 04, 2016, 09:50:15 pm »
I must forget something here, but I can't figure out what ... tried to add ";" to a few places but it still gives an error.

frm1.pas(103,7) Fatal: Syntax error, ";" expected but "identifier STATUSBAR1" found

Well the message is a bit cryptic but it does point you to the exact location you have the problem. What if I told you that the compiler expects a semicolon before the "StatusBar1.SimpleText:=Format(...." command. Will that help you find the missing semicolon?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

scons

  • Full Member
  • ***
  • Posts: 141
Re: code check
« Reply #2 on: February 04, 2016, 10:09:49 pm »
thanks for your reply,

no, not really, if I put a ';' after the end before the Statusbar1, I get an error, If I put that ';' after the end that is before this end, I get an error, If I put a';' at both end's, I get an error.

So really I don't see it,

I looked at this page but it didn't get me any further.

Windows 10-64bit Lazarus 3.2 + FPC 3.2.2

FTurtle

  • Sr. Member
  • ****
  • Posts: 292
Re: code check
« Reply #3 on: February 04, 2016, 11:18:01 pm »
1. Line 32: Add ";" (it is not necessary, but make it a rule)
2. Line 33: Add ";" (necessarily)
3. Line 44: Add "end;"

After JEDI Code Format it will look:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button3Click(Sender: TObject);
  2. var
  3.   sa: string;
  4.   sb: string;
  5.   sc: string;
  6.   myDateTime1: TDateTime;
  7.   myDateTime2: TDateTime;
  8.   myDateTime3: TDateTime;
  9.   oldName, newName: string;
  10.   i, renameCount: integer;
  11.   NameA, nameB: string;
  12. begin
  13.   myDateTime1 := 0;
  14.   myDateTime2 := 42410;
  15.   myDateTime3 := now();
  16.   sc := FormatDateTime('dd.mm.yyyy', myDateTime3);
  17.   if myDateTime3 < myDateTime2 then
  18.   begin
  19.     if (ListBox1.Count > 0) then
  20.     begin
  21.       renameCount := 0;
  22.       for i := 0 to ListBox1.Count - 1 do
  23.       begin
  24.         if ExtractFileExt(ListBox1.Items[i]) = ('.txt') then
  25.         begin
  26.           NameA := (extractFilePath(Listbox1.Items[i]));
  27.           NameB := Copy((extractFileName(Listbox1.Items[i])), 5, 10);
  28.           oldName := ListBox1.Items[i];
  29.           newName := (NameA) + (Edit1.Text) + (NameB);
  30.           if RenameFileUTF8(oldName, newName) then
  31.             Inc(renameCount);
  32.         end;
  33.       end;
  34.       StatusBar1.SimpleText := Format('  %d files renamed', [renameCount]);
  35.     end
  36.     else
  37.     begin
  38.       sleep(200);
  39.       ShowMessage('You waited too long' + sLineBreak + 'Expired at ' + sc);
  40.       sleep(200);
  41.       Close;
  42.     end;
  43.   end;
  44. end;


scons

  • Full Member
  • ***
  • Posts: 141
Re: code check
« Reply #4 on: February 05, 2016, 12:54:45 am »
no sorry, still no luck
Windows 10-64bit Lazarus 3.2 + FPC 3.2.2

FTurtle

  • Sr. Member
  • ****
  • Posts: 292
Re: code check
« Reply #5 on: February 05, 2016, 01:21:36 am »
This is whole module which I compiled:

Code: Pascal  [Select][+][-]
  1. unit unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   ComCtrls;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     Button1: TButton;
  17.     Button2: TButton;
  18.     Button3: TButton;
  19.     Edit1: TEdit;
  20.     ListBox1: TListBox;
  21.     StatusBar1: TStatusBar;
  22.     procedure Button3Click(Sender: TObject);
  23.   private
  24.     { private declarations }
  25.   public
  26.     { public declarations }
  27.   end;
  28.  
  29. var
  30.   Form1: TForm1;
  31.  
  32. implementation
  33.  
  34. {$R *.lfm}
  35.  
  36. procedure TForm1.Button3Click(Sender: TObject);
  37. var
  38.   sa: string;
  39.   sb: string;
  40.   sc: string;
  41.   myDateTime1: TDateTime;
  42.   myDateTime2: TDateTime;
  43.   myDateTime3: TDateTime;
  44.   oldName, newName: string;
  45.   i, renameCount: integer;
  46.   NameA, nameB: string;
  47. begin
  48.   myDateTime1 := 0;
  49.   myDateTime2 := 42410;
  50.   myDateTime3 := now();
  51.   sc := FormatDateTime('dd.mm.yyyy', myDateTime3);
  52.   if myDateTime3 < myDateTime2 then
  53.   begin
  54.     if (ListBox1.Count > 0) then
  55.     begin
  56.       renameCount := 0;
  57.       for i := 0 to ListBox1.Count - 1 do
  58.       begin
  59.         if ExtractFileExt(ListBox1.Items[i]) = ('.txt') then
  60.         begin
  61.           NameA := (extractFilePath(Listbox1.Items[i]));
  62.           NameB := Copy((extractFileName(Listbox1.Items[i])), 5, 10);
  63.           oldName := ListBox1.Items[i];
  64.           newName := (NameA) + (Edit1.Text) + (NameB);
  65.           if RenameFileUTF8(oldName, newName) then
  66.             Inc(renameCount);
  67.         end;
  68.       end;
  69.       StatusBar1.SimpleText := Format('  %d files renamed', [renameCount]);
  70.     end
  71.     else
  72.     begin
  73.       sleep(200);
  74.       ShowMessage('You waited too long' + sLineBreak + 'Expired at ' + sc);
  75.       sleep(200);
  76.       Close;
  77.     end;
  78.   end;
  79. end;
  80.  
  81. end.
  82.  

scons

  • Full Member
  • ***
  • Posts: 141
Re: code check
« Reply #6 on: February 05, 2016, 02:00:02 am »
allright, got it now !

thanks for helping out guys.
Windows 10-64bit Lazarus 3.2 + FPC 3.2.2

 

TinyPortal © 2005-2018