Recent

Author Topic: This is terable!  (Read 320 times)

JLWest

  • Sr. Member
  • ****
  • Posts: 340
This is terable!
« on: December 30, 2018, 01:14:35 am »
Code: Pascal  [Select]
  1. procedure TForm1.DeleteRecordsListbox1(Const aStart : Integer);
  2.   Var
  3.    StartIdx : Integer = -1;
  4.    Idx      : Integer = -1;
  5.    RCD      : String = 'RC099';
  6.    TFRecord : String = '';
  7.    Done     : Boolean = False;
  8.   begin
  9.   StartIdx := aStart;
  10.   Done := False;
  11.    Repeat
  12.      ListBox1.Selected[StartIdx] := True;
  13.      TFRecord := ListBox1.Items[StartIdx];
  14.      RCD := Copy2Space(TFRecord);
  15.      [color=red]if (RCD = 'RC099') then
  16.         Done := True
  17.      else
  18.         ListBox1.Items.Delete (StartIdx)
  19.         Inc(StartIdx);[/color]
  20.      until Done;
  21.    end;  

unit1.pas(457,6) Fatal: Syntax error, "UNTIL" expected but "ELSE" found

I can't write an if statement, if then else. I can't get it to compile and when it dose I'm never sure how it will react or the results.

This one won't compile. I have no idea why its looking for an UNTIL.
JLWEST 
 FPC 3.0.4, Lazarus IDE v1.8.2 Windows 10 Pro
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig 1.5 Terabyte SSD
3 Terabyte conventional disk space.

lucamar

  • Hero Member
  • *****
  • Posts: 734
Re: This is terable!
« Reply #1 on: December 30, 2018, 01:27:42 am »
Try this:
Code: Pascal  [Select]
  1.   Repeat
  2.     ListBox1.Selected[StartIdx] := True;
  3.     TFRecord := ListBox1.Items[StartIdx];
  4.     RCD := Copy2Space(TFRecord);
  5.     if (RCD = 'RC099') then
  6.        Done := True
  7.     else
  8.        ListBox1.Items.Delete (StartIdx);
  9.     Inc(StartIdx);
  10.   until Done;

There was a missing ; in the line:
       ListBox1.Items.Delete (StartIdx)


BTW, to highlight one or more lines write your [ code ] tags like: [ code=Pascal,8,10 ] for example--without the spaces, of course :)

ETA: Oh! What does "terable" mean? Or did you meant "terrible"
« Last Edit: December 30, 2018, 01:34:12 am by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 1.8.4/FPC 3.0.4 on:
(K)Ubuntu 12..16, Windows XP SP3 (Home/Prof.) and various DOS incarnations.

JLWest

  • Sr. Member
  • ****
  • Posts: 340
Re: This is terable!
« Reply #2 on: December 30, 2018, 01:41:06 am »
In the old English Dictionary "terable" is worst than "terrible" or it could just be along with the inability to write Pascal I can't spell.   
JLWEST 
 FPC 3.0.4, Lazarus IDE v1.8.2 Windows 10 Pro
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig 1.5 Terabyte SSD
3 Terabyte conventional disk space.

lucamar

  • Hero Member
  • *****
  • Posts: 734
Re: This is terable!
« Reply #3 on: December 30, 2018, 01:43:40 am »
Well, I don't know about "terable" but your Pascal is not that bad; just the standard typos everyone makes some time or other.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 1.8.4/FPC 3.0.4 on:
(K)Ubuntu 12..16, Windows XP SP3 (Home/Prof.) and various DOS incarnations.

JLWest

  • Sr. Member
  • ****
  • Posts: 340
Re: This is terable!
« Reply #4 on: December 30, 2018, 01:59:44 am »
Thanks for being kind.

JLWEST 
 FPC 3.0.4, Lazarus IDE v1.8.2 Windows 10 Pro
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig 1.5 Terabyte SSD
3 Terabyte conventional disk space.