Recent

Author Topic: Problems getting started [SOLVED]  (Read 572 times)

DaveP

  • New Member
  • *
  • Posts: 13
Problems getting started [SOLVED]
« on: May 25, 2022, 01:40:53 pm »
Hi,  I am trying to convert some DOS Modula-2 programs I wrote in the 90's with the Topspeed M2 Compiler.
Running PC-Linux, and using Lazarus with the crt library for the applications and libraries.
I have added a few lines from the crt library to a simple example programme which compiles Ok.
But I tried adding a procedure to an example library and it fails to compile with the following message.

Compile project1 Target: libproject1.so: Exit code1, Errors: 1   
Project1.pas(31.3) Fatal: Syntax error, "BEGIN" expected but "identifier COLORS" found
 
Code: [Select]
library subs;
uses
  crt;     // crt added to example.

procedure Colors( FgCol, BgCol : Byte );    // Added this procedure
  begin
    TextColor( FgCol );
    TextBackground( BgCol );
  end;

function SubStr(CString: PChar;FromPos,ToPos: Longint): PChar; cdecl;    // Existing example follows.
 //  This is an copied example,
var
  Length: Integer;

begin
  Length := StrLen(CString);
  SubStr := CString + Length;
  if (FromPos > 0) and (ToPos >= FromPos) then
  begin
    if Length >= FromPos then
      SubStr := CString + FromPos;
    if Length > ToPos then
    CString[ToPos+1] := #0;
  end;
end;
project1
exports
  SubStr;
  Colors;
end.                                 

I don't understand why this fails, but if armed with a simple working library I think I can make some progress towards converting the first program.
« Last Edit: May 26, 2022, 11:11:17 pm by DaveP »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: Problems getting started
« Reply #1 on: May 25, 2022, 02:19:05 pm »
Code: Pascal  [Select][+][-]
  1. project1   // remove this  
  2. exports
  3.   SubStr;   // exports expects a list separated by commas, terminated with semcolon. So  exports substr,  colors;  not substr;colors;
  4.   Colors;
  5. end.      

Red_prig

  • Full Member
  • ***
  • Posts: 143
Re: Problems getting started
« Reply #2 on: May 25, 2022, 02:19:34 pm »
Quote
//project1
exports
  SubStr;
  Colors;
end. 

the project1 line is not needed here

DaveP

  • New Member
  • *
  • Posts: 13
Re: Problems getting started
« Reply #3 on: May 25, 2022, 03:42:34 pm »
Many thanks for the replies.  Now compiles Ok.  I can now get on with expanding the simple code bits into something useful, and on to another problem I guess.
DaveP..

MarkMLl

  • Hero Member
  • *****
  • Posts: 6686
Re: Problems getting started
« Reply #4 on: May 25, 2022, 04:04:54 pm »
Subject to Marco's confirmation, but I'd suggest not trying to mix the Crt library etc. with GUI-oriented application programming.

Apart from that I don't think you'll have too many problems unless your code has coroutines (including interrupt handlers) although you will obviously need to watch out for the "dangling else" problem.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018