Recent

Author Topic: Create library, why not compile [ SOLVED ]  (Read 743 times)

DaveP

  • New Member
  • *
  • Posts: 13
Create library, why not compile [ SOLVED ]
« on: September 20, 2023, 11:11:26 pm »
Hi, I need a hand to get going with creating a few libraries, that I want to convert from DOS Modula2. and already stuck with the following that gives a compile error that I cannot understand.
If someone would clarify the code , it would be a great help and enable me to press on.

MyLib.pas(47,3) Fatal: Syntax error, ";" expected but "identifier CLEARLINES"

( Capitals, I prefer them in some places, and its only for myself  )
Dave P..

Code: Pascal  [Select][+][-]
  1. procedure Clearline( Y, BgCol : byte );
  2. begin
  3.   GotoXY( 1, Y );
  4.   TextBackground( BgCol );
  5.   ClrEol;
  6. end;
  7.  
  8.  
  9. procedure ClearLines( y1, y2, BgCol : byte );
  10.  
  11. var
  12.   J : byte;
  13. begin
  14.   TextBackground( BgCol );
  15.   for J := y1 TO y2 DO
  16.     GotoXY( 1, J );
  17.     ClrEol;
  18.   // end for
  19. end;
  20.  
  21.  procedure Colors( FgCol, BgCol : Byte );
  22.  begin
  23.     TextColor( FgCol );
  24.     TextBackground( BgCol );
  25.   end;
  26.  
  27. exports
  28.   ClearLine;
  29.   ClearLines;
  30.   Colors;
  31. END.                              
  32.  
« Last Edit: September 21, 2023, 06:54:06 pm by DaveP »

jamie

  • Hero Member
  • *****
  • Posts: 6734
Re: Create library, why not compile
« Reply #1 on: September 20, 2023, 11:22:19 pm »
That may not work so well.

Don't append ";" on the "END"s.

also, you need to employ the CRT unit for those functions.

Being used as a library then I would think you would have Library at the top of your source instead of Program.

In any case, I don't think you are going to get the CRT to work well as a library.


The only true wisdom is knowing you know nothing

Josh

  • Hero Member
  • *****
  • Posts: 1344
Re: Create library, why not compile
« Reply #2 on: September 20, 2023, 11:30:50 pm »
Code: Pascal  [Select][+][-]
  1. procedure ClearLines( y1, y2, BgCol : byte );
  2.  
  3. var
  4.   J : byte;
  5. begin
  6.   TextBackground( BgCol );
  7.   for J := y1 TO y2 DO
  8.     GotoXY( 1, J );
  9.     ClrEol;
  10.   // end for
  11. end;

the for loop will just do gotoxy and will not do clreol untilfor loop has finished, you need to encompass multiple commands in a begin end block ie

Code: Pascal  [Select][+][-]
  1. procedure ClearLines( y1, y2, BgCol : byte );
  2.  
  3. var
  4.   J : byte;
  5. begin
  6.   TextBackground( BgCol );
  7.   for J := y1 TO y2 DO
  8.   begin
  9.     GotoXY( 1, J );
  10.     ClrEol;
  11.   end;
  12. end;

ammended
IIRC exports are comma seperated ie
Code: Pascal  [Select][+][-]
  1. exports
  2.   ClearLine, ClearLines,  Colors;
  3. END.        
« Last Edit: September 21, 2023, 12:08:55 am by Josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

DaveP

  • New Member
  • *
  • Posts: 13
Re: Create library, why not compile
« Reply #3 on: September 21, 2023, 02:25:58 pm »
Many thanks for the replies,  the code compiles ok now.
The top bit of the code that had the "uses" & "library" sections was left off, thought it unnecessary.  However the errors in my code have been clarified very clearly. Thanks again.
The next issue is directory structure, where best to put libraries , but guess that's best in another post.
Dave P.. 

 

TinyPortal © 2005-2018