Bookstore

Recent

Author Topic: Failure to run simple programme  (Read 508 times)

DaveP

  • Newbie
  • Posts: 3
Failure to run simple programme
« on: February 24, 2020, 08:33:55 pm »
Hi, Using PC_Linux (64bit),  Lazarus 2.0.4    Just trying to start with FPC/Laarus, and immediately running into trouble.
I wish to convert some old Topspeed Modula-2 programmes to native Linux, so no graphics stuff required.
Code: [Select]
program project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes
  { you can add units after this };

begin

 Writeln( 'FIRST PROGRAMME ');
 Writeln('Press any Key');
 Writeln('To Exit');
 Readln;
end.             
/CODE

An executable file 'project1' has appeared in the directory with associated files, however trying to run the file I get the following.:-

[dave@localhost L1]$ ls
backup/  project1*     project1.lpi  project1.lps  unit1.lfm
lib/     project1.ico  project1.lpr  project1.res  unit1.pas
[dave@localhost L1]$ project1
bash: project1: command not found
[dave@localhost L1]$

project1 is 1.4MB  ( 1.4mB for a couple of lines of code WOW !! ).

This command worked all Ok,  dave@localhost L1]$ dosbox
So I am stuck, any suggestions most welcome.
Dave P..

ps) is a list of FPC variable types / statements available anywhere ?.

 

MarkMLl

  • Hero Member
  • *****
  • Posts: 704
Re: Failure to run simple programme
« Reply #1 on: February 24, 2020, 08:39:39 pm »
Dave: unix doctrine, . isn't on the path so try ./project1

> project1 is 1.4MB  ( 1.4mB for a couple of lines of code WOW !! ).

Including large amounts of symbolic info for debugging. Still not good, but not quite as bad as it looks.

> ps) is a list of FPC variable types / statements available anywhere ?.

https://www.freepascal.org/docs.html

The HTML variant of the RTL documentation has an index link at the top of each page. However it's very much reference material, apart from the Wiki- maintained sporadically- there's a shortage of "how do I..." material.

MarkMLl
« Last Edit: February 24, 2020, 09:19:51 pm by MarkMLl »
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

DaveP

  • Newbie
  • Posts: 3
Re: Failure to run simple programme
« Reply #2 on: February 24, 2020, 10:48:26 pm »
Thanks for the reply Mark,   Getting somewhere, but not quite what was expected.

[dave@localhost ~]$ ./project1
bash: ./project1: No such file or directory
[dave@localhost ~]$ dave/home/Laz/L1/project1
bash: dave/home/Laz/L1/project1: No such file or directory
[dave@localhost ~]$ ./dave/home/Laz/L1/project1
bash: ./dave/home/Laz/L1/project1: No such file or directory
[dave@localhost ~]$ cd Laz
[dave@localhost Laz]$ cd L1
[dave@localhost L1]$ ./project1                 (* This one worked, sort of *)
FIRST PROGRAMME

Press X
To Exit                                                        (* small change to  the code *)


But the programme prints out in the console. I expected it to run in a new window, which is necessary to be of any use.
My other problem is this, to clear the screen,  set the text and background colour, and position for some user input, should take seconds to code, but I cannot even find any reference to the required statements.
Like :-  Clear;  GotoXY( 2, 1 );  TextColor( Red );   Etc Etc.    without which I cannot make any progress.
Dave P..

Bart

  • Hero Member
  • *****
  • Posts: 3720
    • Bart en Mariska's Webstek
Re: Failure to run simple programme
« Reply #3 on: February 24, 2020, 11:22:04 pm »
My other problem is this, to clear the screen,  set the text and background colour, and position for some user input, should take seconds to code, but I cannot even find any reference to the required statements.
Like :-  Clear;  GotoXY( 2, 1 );  TextColor( Red );   Etc Etc.    without which I cannot make any progress.
Dave P..

They are in the crt unit.

Bart

dbannon

  • Hero Member
  • *****
  • Posts: 977
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Failure to run simple programme
« Reply #4 on: February 24, 2020, 11:40:22 pm »
They are in the crt unit.
Bart

DaveP, if you want things popping up in a new window and easy control of user input and colours and such, you may actually find it easier to make a simple Lazarus GUI app. As Bart says, those tools are in the CRT unit, are quite usable and will do what you want (except, maybe the new window thing) but for probably little or no extra effort you could put a much nicer looking GUI interface on it and end users will will be a lot happier with a more familiar interface.

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

DaveP

  • Newbie
  • Posts: 3
Re: Failure to run simple programme
« Reply #5 on: February 25, 2020, 10:59:36 pm »
I believe it may be possible to have a console programme open in a window, looking at "Run", "Run Parameters" and selecting Help, under "Launching application" but it looks like this requires a script. so I am not sure if that is of any use, or how to use it. In fact anything larger than "Hello World" would be useless in its own window.

I can find no reference to CRT, Can it be used with a console app. ??
A GUI app seems out of the question, as the apps that I wish to convert use a series of menus, extra windows, search ahead on inputs, display of linked lists, Etc Etc. I fear the learning curve would last until the last nail go in my box.
DaveP..

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8064
Re: Failure to run simple programme
« Reply #6 on: February 25, 2020, 11:20:02 pm »
Hi, Using PC_Linux (64bit),  Lazarus 2.0.4    Just trying to start with FPC/Laarus, and immediately running into trouble.
I wish to convert some old Topspeed Modula-2 programmes to native Linux, so no graphics stuff required.

It will be hard. Crt is more awkward than module WINDOW, however Free/Turbo Vision is more advanced. And both are less advanced on *nix, because the terminal type there is a bit more fluid. (which can be easily seen in many full screen text programs avoiding e.g. function key combos)

I attempted to build something FV/TV like on top of Window in the late nineties in TSM2, see the horror here (pulldemo.mod) .

If you would do it for Windows, maybe, but for Linux I think you are walking right into the swamp, and better go gui.

p.s. also have a look at the "lister" example in the demos that come with FPC. Hopefully installed under /usr/share/*/fpc/* somewhere on Penguin OS.
« Last Edit: February 25, 2020, 11:26:31 pm by marcov »

Bart

  • Hero Member
  • *****
  • Posts: 3720
    • Bart en Mariska's Webstek
Re: Failure to run simple programme
« Reply #7 on: February 25, 2020, 11:22:47 pm »
I can find no reference to CRT, Can it be used with a console app. ??

Yes, it is meant for console programming, not for a GUI program.

Code: Pascal  [Select]
  1. program test;
  2. uses crt;
  3.  
  4. var
  5.   Ch: Char;
  6. begin
  7.   CLrScr;  //clear the screen
  8.   GotoXY(2,10);
  9.   write('Press Q to quit: ');
  10.   repeat
  11.     Ch := ReadKey; //read one character from input, without echoing it to the screen
  12.   until (Upcase(Ch) = 'Q');
  13.   writeln('Q');//visual feedback
  14.   gotoxy(12,1);
  15.   writeln('Bye');
  16. end.


A GUI app seems out of the question, as the apps that I wish to convert use a series of menus, extra windows, search ahead on inputs, display of linked lists, Etc Etc.
Menu's, windows: that's screaming for a GUI, where this is normal stuff.
Using Lazarus, you can build a menu easily.

I fear the learning curve would last until the last nail go in my box.

You must be either very old then, or terminally ill  O:-)

Bart

dbannon

  • Hero Member
  • *****
  • Posts: 977
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Failure to run simple programme
« Reply #8 on: February 26, 2020, 03:04:46 am »
I believe it may be possible to have a console programme open in a window, looking at "Run", ......

It may be possible to ride a push bike across the Simpson Desert but you won't catch me doing it !

Dave, please have a look through the first part of this -
https://wiki.freepascal.org/Lazarus_Tutorial

and then jump to https://wiki.freepascal.org/Lazarus_Tutorial#Menu_controls

Once you climb over that learning curve, you will be amazed how easy it all becomes.  And this forum is very welcoming of beginners and very helpful with things that the individual members are good at. And, these days the cursor driven interfaces are something no one is good at !  They are very hard to maintain and users hate them.

Davo

Edit:  Join us, do not be afraid, you will be assimilated ....

Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng