Recent

Author Topic: [SOLVED]"Unit expected but Program found!?" Whats wrong?  (Read 1541 times)

coradi

  • Jr. Member
  • **
  • Posts: 91
[SOLVED]"Unit expected but Program found!?" Whats wrong?
« on: October 31, 2019, 01:13:58 pm »
Program xyz;
 Begin
end.


this works BUT

Program xyz;
Uses crt;
 Begin
end.

not?!
Unit expected but Program found!?

All my old Programs doesn't work to..the same failure message?
« Last Edit: November 01, 2019, 07:50:57 am by coradi »
Amstrad Schneider CPC 6128
Wind XP / 7 / 10

RayoGlauco

  • Full Member
  • ***
  • Posts: 108
  • Beers: 1567
Re: Whats wrong?
« Reply #1 on: October 31, 2019, 01:52:51 pm »
For me, it compiles ok, as a "simple program" project.
Lazarus 2.0.4, Windows 8
To err is human, but to really mess things up, you need a computer.

coradi

  • Jr. Member
  • **
  • Posts: 91
Re: Whats wrong?
« Reply #2 on: October 31, 2019, 02:10:36 pm »
There seems a  big problem?!

If I compile it in freepascal folder..it seems to wordk..If i say
save to.c:\Tools\Pascal\test.pas

Then it says..the message with the Unit!??!
BUT!!!
If i then say ok..then save it in an other order.then I only get a windows..to save the Listbox.txt!??!?!?!?
It isn't possible then to save the .pas file anymore.
If I THEN try to read an old pas file an try to compile it.I got th same failure message?!
If i close FPC and open it again and try to compile an old project it works fine..till i try to copmpile it like before..then error Message again..and then nothing will compile anymore

« Last Edit: October 31, 2019, 02:23:55 pm by coradi »
Amstrad Schneider CPC 6128
Wind XP / 7 / 10

coradi

  • Jr. Member
  • **
  • Posts: 91
other proplem?!
« Reply #3 on: October 31, 2019, 02:36:56 pm »
Why isn't allowed the
 Program Windows;

If I do this , this happens


If i reanem Windows in xyz, it works
Amstrad Schneider CPC 6128
Wind XP / 7 / 10

MarkMLl

  • Hero Member
  • *****
  • Posts: 1233
Re: Whats wrong?
« Reply #4 on: October 31, 2019, 02:48:04 pm »
What happens if you try to compile your file using the fpc compiler invoked at the command line?

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.

glorfin

  • Full Member
  • ***
  • Posts: 108
Re: Whats wrong?
« Reply #5 on: October 31, 2019, 03:12:05 pm »
(1) Try saving your program to a file with the name equal to the program name (program test in test.pas). Not quite sure, but I think it may help.
(2) There is unti Windows in fpc, which is probably used by default, and this makes your unit or program Windows impossible.

Regards!

coradi

  • Jr. Member
  • **
  • Posts: 91
Re: Whats wrong?
« Reply #6 on: October 31, 2019, 03:35:37 pm »
Yes, but My is names Windows1 not Windows
Amstrad Schneider CPC 6128
Wind XP / 7 / 10

coradi

  • Jr. Member
  • **
  • Posts: 91
Re: Whats wrong?
« Reply #7 on: October 31, 2019, 03:43:12 pm »
What happens if you try to compile your file using the fpc compiler invoked at the command line?

MarkMLl

Oh...with Turbo PAscal / I know how I do that..but there is no TPC or TP.exe...
How I do hat?
Amstrad Schneider CPC 6128
Wind XP / 7 / 10

MarkMLl

  • Hero Member
  • *****
  • Posts: 1233
Re: Whats wrong?
« Reply #8 on: October 31, 2019, 03:48:51 pm »
Use the fpc command, like I said. I'd have expected that to have been put on the system path.

https://www.freepascal.org/docs-html/current/user/userse10.html
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.

coradi

  • Jr. Member
  • **
  • Posts: 91
Re: Whats wrong?
« Reply #9 on: October 31, 2019, 06:02:36 pm »
exactly the same


but why he comile both?!?
I wrote fpc sdfs.pas

and got this error Message and none of both are compiled
I already tried a Reboot and a new Install and a erlier FPC Version
« Last Edit: October 31, 2019, 06:05:47 pm by coradi »
Amstrad Schneider CPC 6128
Wind XP / 7 / 10

Handoko

  • Hero Member
  • *****
  • Posts: 3765
  • My goal: build my own game engine using Lazarus
Re: Whats wrong?
« Reply #10 on: October 31, 2019, 06:28:25 pm »
Maybe you need to run a scandisk or chkdsk c: /f
I know some disk issues may make PC works weirdly.

Have you try to install and run Lazarus to see if it works correctly?

On the post #9, the picture shows the file name is windows.pas. You should rename it because it may conflict with the unit windows.
« Last Edit: October 31, 2019, 06:43:55 pm by Handoko »

coradi

  • Jr. Member
  • **
  • Posts: 91
Re: Whats wrong?
« Reply #11 on: October 31, 2019, 07:06:11 pm »
I will try it later on an other Laptop
Amstrad Schneider CPC 6128
Wind XP / 7 / 10

Thaddy

  • Hero Member
  • *****
  • Posts: 10482
Re: Whats wrong?
« Reply #12 on: October 31, 2019, 07:18:28 pm »
It is really simple: the program declaration must *exactly* match the program filename on disk. (or omitted altogether) and in the same case including extension.
Code: Pascal  [Select][+][-]
  1. {$mode objfpc}
  2. program test;  // on disk must be test.pp or test.pas or test.lpr NOT tesT or Test or test.PAS or Tset.Pas
  3. begin
  4. end.

Omitting program altogether is also valid:
Code: Pascal  [Select][+][-]
  1. {$mode objfpc}
  2. begin
  3. end.
« Last Edit: October 31, 2019, 07:26:06 pm by Thaddy »
When you ask a question that is actually answered in the documentation, you are either lazy or a moron.

Handoko

  • Hero Member
  • *****
  • Posts: 3765
  • My goal: build my own game engine using Lazarus
Re: Whats wrong?
« Reply #13 on: October 31, 2019, 07:41:59 pm »
If it is true, it should be documented. But I found no information that program declaration must exactly math the program filename:

https://wiki.freepascal.org/Program_Structure
https://www.tutorialspoint.com/pascal/pascal_program_structure.htm
https://tech-story.net/pascal-program-structures/

Delphi did mention it but it said only for application developed using CodeGear:

Quote
The program heading specifies a name for the executable program. It consists of the reserved word program, followed by a valid identifier, followed by a semicolon. For applications developed using CodeGear tools, the identifier must match the project source file name.
Source: http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/programsandunitsov_xml.html

coradi

  • Jr. Member
  • **
  • Posts: 91
Re: Whats wrong?
« Reply #14 on: November 01, 2019, 01:14:43 am »
<this would be new for me too. No -i don't think so..but I wll try. Turbo Pascal don't need this.
Why should it?
Amstrad Schneider CPC 6128
Wind XP / 7 / 10

 

TinyPortal © 2005-2018