Syntax error unit expected but program found

Syntax error unit expected but program found alexmlw » 15.01.2011 16:52:17 при компилировании выскакивает ошибка «Syntax error, «UNIT» expected but «USES» found» Добавлено спустя 27 минут 41 секунду: эту ошибку исправил но вместо нее теперь другая Can’t find unit Graph used by Program как ее исправить? Re: Syntax error, «UNIT» expected but «USES» found […]

Содержание

  1. Syntax error unit expected but program found
  2. Re: Syntax error, «UNIT» expected but «USES» found
  3. Re: Syntax error, «UNIT» expected but «USES» found
  4. Re: Syntax error, «UNIT» expected but «USES» found
  5. Re: Syntax error, «UNIT» expected but «USES» found
  6. Re: Syntax error, «UNIT» expected but «USES» found
  7. Re: Syntax error, «UNIT» expected but «USES» found
  8. Re: Syntax error, «UNIT» expected but «USES» found
  9. Re: Syntax error, «UNIT» expected but «USES» found
  10. Syntax error unit expected but program found
  11. Re: Syntax error, «UNIT» expected but «USES» found
  12. Re: Syntax error, «UNIT» expected but «USES» found
  13. Re: Syntax error, «UNIT» expected but «USES» found
  14. Re: Syntax error, «UNIT» expected but «USES» found
  15. Re: Syntax error, «UNIT» expected but «USES» found
  16. Re: Syntax error, «UNIT» expected but «USES» found
  17. Re: Syntax error, «UNIT» expected but «USES» found
  18. Re: Syntax error, «UNIT» expected but «USES» found
  19. [Паскалъ] Need Help

Syntax error unit expected but program found

alexmlw » 15.01.2011 16:52:17

при компилировании выскакивает ошибка «Syntax error, «UNIT» expected but «USES» found»

Добавлено спустя 27 минут 41 секунду:
эту ошибку исправил но вместо нее теперь другая Can’t find unit Graph used by Program как ее исправить?

Re: Syntax error, «UNIT» expected but «USES» found

Nik » 15.01.2011 18:02:56

Re: Syntax error, «UNIT» expected but «USES» found

Little_Roo » 15.01.2011 18:03:43

alexmlw писал(а): при компилировании выскакивает ошибка «Syntax error, «UNIT» expected but «USES» found»

Добавлено спустя 27 минут 41 секунду:
эту ошибку исправил но вместо нее теперь другая Can’t find unit Graph used by Program как ее исправить?

Re: Syntax error, «UNIT» expected but «USES» found

alexmlw » 15.01.2011 18:20:44

Re: Syntax error, «UNIT» expected but «USES» found

Vadim » 15.01.2011 20:17:56

Re: Syntax error, «UNIT» expected but «USES» found

alexmlw » 15.01.2011 23:39:32

тоже самое ток вместо graph ругается на ggigraph

Re: Syntax error, «UNIT» expected but «USES» found

Иван Шихалев » 15.01.2011 23:46:08

Re: Syntax error, «UNIT» expected but «USES» found

trius-strannik » 15.01.2011 23:49:21

Re: Syntax error, «UNIT» expected but «USES» found

alexmlw » 15.01.2011 23:53:42

#
# Example fpc.cfg for Free Pascal Compiler
#

#
# nested #IFNDEF, #IFDEF, #ENDIF, #ELSE, #DEFINE, #UNDEF are allowed
#
# -d is the same as #DEFINE
# -u is the same as #UNDEF
#

#
# Some examples (for switches see below, and the -? helppages)
#
# Try compiling with the -dRELEASE or -dDEBUG on the commandline
#

# For a release compile with optimizes and strip debuginfo
#IFDEF RELEASE
-O2
-Xs
#WRITE Compiling Release Version
#ENDIF

# For a debug version compile with debuginfo and all codegeneration checks on
#IFDEF DEBUG
-g
-Crtoi
#WRITE Compiling Debug Version
#ENDIF

# set binutils prefix

#IFNDEF CPUI386
#IFNDEF CPUAMD64
#DEFINE NEEDCROSSBINUTILS
#ENDIF
#ENDIF

#IFNDEF linux
#DEFINE NEEDCROSSBINUTILS
#ENDIF

#IFDEF FPC_CROSSCOMPILING
#IFDEF NEEDCROSSBINUTILS
-XP$fpctarget-
#ENDIF NEEDCROSSBINUTILS
#ENDIF

# assembling
#ifdef darwin
# use pipes instead of temporary files for assembling
-ap
#endif

# Pascal language mode
# -Mfpc free pascal dialect (default)
# -Mobjfpc switch some Delphi 2 extensions on
# -Mdelphi tries to be Delphi compatible
# -Mtp tries to be TP/BP 7.0 compatible
# -Mgpc tries to be gpc compatible
# -Mmacpas tries to be compatible to the macintosh pascal dialects
#
# Turn on Object Pascal extensions by default
#-Mobjfpc

# Assembler reader mode
# -Rdefault use default assembler
# -Ratt read AT&T style assembler
# -Rintel read Intel style assembler
#
# All assembler blocks are AT&T styled by default
#-Ratt

# Semantic checking
# -S2 same as -Mobjfpc
# -Sc supports operators like C (*=,+=,/= and -=)
# -Sa include assertion code.
# -Sd same as -Mdelphi
# -Se error options. is a combination of the following:
# : compiler stops after the errors (default is 1)
# w : compiler stops also after warnings
# n : compiler stops also after notes
# h : compiler stops also after hints
# -Sg allow LABEL and GOTO
# -Sh Use ansistrings
# -Si support C++ styled INLINE
# -Sk load fpcylix unit
# -SI set interface style to
# -SIcom COM compatible interface (default)
# -SIcorba CORBA compatible interface
# -Sm support macros like C (global)
# -So same as -Mtp
# -Sp same as -Mgpc
# -Ss constructor name must be init (destructor must be done)
# -St allow static keyword in objects
# -Sx enable exception keywords (default in Delphi/ObjFPC modes)
#
# Allow goto, inline, C-operators, C-vars
-Sgic

# Uncomment the next line if you always want static/dynamic units by default
# (can be overruled with -CD, -CS at the commandline)
#-CS
#-CD

# Set the default heapsize to 8Mb
#-Ch8000000

# Set default codegeneration checks (iocheck, overflow, range, stack)
#-Ci
#-Co
#-Cr
#-Ct

# Optimizer switches
# -Os generate smaller code
# -O1 level 1 optimizations (quick optimizations, debuggable)
# -O2 level 2 optimizations (-O1 + optimizations which make debugging more difficult)
# -O3 level 3 optimizations (-O2 + optimizations which also may make the program slower rather than faster)
# -Op set target cpu for optimizing, see fpc -i for possible values
#
# See «fpc -i» also for more fine-grained control over which optimizations
# to perform

#ifdef darwin
#ifdef cpui386
-Cppentiumm
-Oppentiumm
#endif
#endif

# Slashes are also allowed under dos

# path to the messagefile, not necessary anymore but can be used to override
# the default language
#-Fr/usr/lib/fpc/$fpcversion/msg/errore.msg
#-Fr/usr/lib/fpc/$fpcversion/msg/errorn.msg

#IFDEF FPCAPACHE_1_3
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd13/
#ELSE
#IFDEF FPCAPACHE_2_0
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd20
#ELSE
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd22
#ENDIF
#ENDIF

# searchpath for units and other system dependent things
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
#-Fu

# searchpath for libraries
#ifdef cpux86_64
-Fl/usr/lib/gcc/x86_64-linux-gnu/4.4.5
#endif

# generate always debugging information for GDB (slows down the compiling
# process)
# -gc generate checks for pointers
# -gd use dbx
# -gg use gsym
# -gh use heap trace unit (for memory leak debugging)
# -gl use line info unit to show more info for backtraces
# -gv generates programs tracable with valgrind
# -gw generate dwarf debugging info
#
# Enable debuginfo and use the line info unit by default
#-gl

# always pass an option to the linker
#-k-s

# Always strip debuginfo from the executable
-Xs

Источник

Syntax error unit expected but program found

alexmlw » 15.01.2011 16:52:17

при компилировании выскакивает ошибка «Syntax error, «UNIT» expected but «USES» found»

Добавлено спустя 27 минут 41 секунду:
эту ошибку исправил но вместо нее теперь другая Can’t find unit Graph used by Program как ее исправить?

Re: Syntax error, «UNIT» expected but «USES» found

Nik » 15.01.2011 18:02:56

Re: Syntax error, «UNIT» expected but «USES» found

Little_Roo » 15.01.2011 18:03:43

alexmlw писал(а): при компилировании выскакивает ошибка «Syntax error, «UNIT» expected but «USES» found»

Добавлено спустя 27 минут 41 секунду:
эту ошибку исправил но вместо нее теперь другая Can’t find unit Graph used by Program как ее исправить?

Re: Syntax error, «UNIT» expected but «USES» found

alexmlw » 15.01.2011 18:20:44

Re: Syntax error, «UNIT» expected but «USES» found

Vadim » 15.01.2011 20:17:56

Re: Syntax error, «UNIT» expected but «USES» found

alexmlw » 15.01.2011 23:39:32

тоже самое ток вместо graph ругается на ggigraph

Re: Syntax error, «UNIT» expected but «USES» found

Иван Шихалев » 15.01.2011 23:46:08

Re: Syntax error, «UNIT» expected but «USES» found

trius-strannik » 15.01.2011 23:49:21

Re: Syntax error, «UNIT» expected but «USES» found

alexmlw » 15.01.2011 23:53:42

#
# Example fpc.cfg for Free Pascal Compiler
#

#
# nested #IFNDEF, #IFDEF, #ENDIF, #ELSE, #DEFINE, #UNDEF are allowed
#
# -d is the same as #DEFINE
# -u is the same as #UNDEF
#

#
# Some examples (for switches see below, and the -? helppages)
#
# Try compiling with the -dRELEASE or -dDEBUG on the commandline
#

# For a release compile with optimizes and strip debuginfo
#IFDEF RELEASE
-O2
-Xs
#WRITE Compiling Release Version
#ENDIF

# For a debug version compile with debuginfo and all codegeneration checks on
#IFDEF DEBUG
-g
-Crtoi
#WRITE Compiling Debug Version
#ENDIF

# set binutils prefix

#IFNDEF CPUI386
#IFNDEF CPUAMD64
#DEFINE NEEDCROSSBINUTILS
#ENDIF
#ENDIF

#IFNDEF linux
#DEFINE NEEDCROSSBINUTILS
#ENDIF

#IFDEF FPC_CROSSCOMPILING
#IFDEF NEEDCROSSBINUTILS
-XP$fpctarget-
#ENDIF NEEDCROSSBINUTILS
#ENDIF

# assembling
#ifdef darwin
# use pipes instead of temporary files for assembling
-ap
#endif

# Pascal language mode
# -Mfpc free pascal dialect (default)
# -Mobjfpc switch some Delphi 2 extensions on
# -Mdelphi tries to be Delphi compatible
# -Mtp tries to be TP/BP 7.0 compatible
# -Mgpc tries to be gpc compatible
# -Mmacpas tries to be compatible to the macintosh pascal dialects
#
# Turn on Object Pascal extensions by default
#-Mobjfpc

# Assembler reader mode
# -Rdefault use default assembler
# -Ratt read AT&T style assembler
# -Rintel read Intel style assembler
#
# All assembler blocks are AT&T styled by default
#-Ratt

# Semantic checking
# -S2 same as -Mobjfpc
# -Sc supports operators like C (*=,+=,/= and -=)
# -Sa include assertion code.
# -Sd same as -Mdelphi
# -Se error options. is a combination of the following:
# : compiler stops after the errors (default is 1)
# w : compiler stops also after warnings
# n : compiler stops also after notes
# h : compiler stops also after hints
# -Sg allow LABEL and GOTO
# -Sh Use ansistrings
# -Si support C++ styled INLINE
# -Sk load fpcylix unit
# -SI set interface style to
# -SIcom COM compatible interface (default)
# -SIcorba CORBA compatible interface
# -Sm support macros like C (global)
# -So same as -Mtp
# -Sp same as -Mgpc
# -Ss constructor name must be init (destructor must be done)
# -St allow static keyword in objects
# -Sx enable exception keywords (default in Delphi/ObjFPC modes)
#
# Allow goto, inline, C-operators, C-vars
-Sgic

# Uncomment the next line if you always want static/dynamic units by default
# (can be overruled with -CD, -CS at the commandline)
#-CS
#-CD

# Set the default heapsize to 8Mb
#-Ch8000000

# Set default codegeneration checks (iocheck, overflow, range, stack)
#-Ci
#-Co
#-Cr
#-Ct

# Optimizer switches
# -Os generate smaller code
# -O1 level 1 optimizations (quick optimizations, debuggable)
# -O2 level 2 optimizations (-O1 + optimizations which make debugging more difficult)
# -O3 level 3 optimizations (-O2 + optimizations which also may make the program slower rather than faster)
# -Op set target cpu for optimizing, see fpc -i for possible values
#
# See «fpc -i» also for more fine-grained control over which optimizations
# to perform

#ifdef darwin
#ifdef cpui386
-Cppentiumm
-Oppentiumm
#endif
#endif

# Slashes are also allowed under dos

# path to the messagefile, not necessary anymore but can be used to override
# the default language
#-Fr/usr/lib/fpc/$fpcversion/msg/errore.msg
#-Fr/usr/lib/fpc/$fpcversion/msg/errorn.msg

#IFDEF FPCAPACHE_1_3
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd13/
#ELSE
#IFDEF FPCAPACHE_2_0
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd20
#ELSE
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd22
#ENDIF
#ENDIF

# searchpath for units and other system dependent things
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
#-Fu

# searchpath for libraries
#ifdef cpux86_64
-Fl/usr/lib/gcc/x86_64-linux-gnu/4.4.5
#endif

# generate always debugging information for GDB (slows down the compiling
# process)
# -gc generate checks for pointers
# -gd use dbx
# -gg use gsym
# -gh use heap trace unit (for memory leak debugging)
# -gl use line info unit to show more info for backtraces
# -gv generates programs tracable with valgrind
# -gw generate dwarf debugging info
#
# Enable debuginfo and use the line info unit by default
#-gl

# always pass an option to the linker
#-k-s

# Always strip debuginfo from the executable
-Xs

Источник

[Паскалъ] Need Help

Что программа должна делать(на пхп)

ЕМНИП перед else там точка с запятой не ставится.

Не, ругается на другое, и спасибо это пофиксил.

> перед else там точка с запятой не ставится.

> ругается на другое

Условия в скобки попробуй.

Перед else ; не ставится.

У readln точно такой синтаксис? (я уже запамятовал)

Условия в скобки не надо?

Операции сравнения в скобки возьми.

А теперь, дружище, запомни, что вот этот выхлоп

untitled.pas(26,7) Error: Incompatible types: got «Boolean» expected «LongInt»
untitled.pas(28,2) Fatal: Syntax error, «;» expected but «ELSE» found

должен читать ТЫ сам, а не ЛОР.

Свободно говорю на Русском, Литовском, Английском.

Свободно говорю на Английском

Error: Incompatible types: got «Boolean» expected «LongInt»

Fatal: Syntax error, «;» expected but «ELSE» found

Источник

  • Печать

Страницы: [1]   Вниз

Тема: Помогите зеленому с паскалем.  (Прочитано 4178 раз)

0 Пользователей и 1 Гость просматривают эту тему.

Оффлайн
wannabebrucelee

В общем в универе ща паскаль проходят, хочу познать его на уровне решения лаб :), но есть проблема. У меня чёт не получается настоить инструменталий или я чёто не то делаю.
В общем ubuntu 9.10,  на неё поставил Lazarus.
В source editor пишу:

program hello;
var
   i;
begin
 i := 0;
WriteLn(i);
Write (‘Hello’);
ReadLn;
end.

Потом нажимаю на зелёную стрелку и вылазит сообщение:   unit1.pas(1,1) Fatal: Syntax error, «UNIT» expected but «PROGRAM» found

Что я делаю не так ( чую, что я всё делаю не так…),  Но просто никогда не пользовался подобными программами. Я просто боле мене знаком с вебом(php, css) и там всё совсем по другому.
В общем помогите глупому быдлокодеру разобраться с инструменталием.


Оффлайн
MaSsoL

Может тип переменной объявить?


Оффлайн
jef


Оффлайн
wannabebrucelee

program hello;
var
i: Word;
begin
i:= 0;
WriteLn(i);
Write(‘Hello’);
ReadLn;
end.           

вроде так.
Так?)
Ну это всё тоже самое выдаёт и получается.


Оффлайн
wl

Учите Паскаль, все же придется это сделать.
Разберитесь чем unit отличается от program.

unit1.pas(1,1) Fatal: Syntax error, «UNIT» expected but «PROGRAM» found

unit (модуль) — это библиотека функций и классов, а program — это программа.
Модулей в программе может быть много, но точка входа в исполняемый код всего одна, и она в программе.

Я никогда не программировал в лазарусе, а паскаль еще 10 лет назад в институте забыл как страшный сон.
Но думаю, что там надо организовать проект, дать возможность отработать визардам, чтобы компилятор получил на вход правильную команду.

Возможно, лазарус — это стрельба из пушки по воробьям, и в Вашем случае достаточно будет free pascal и текстового редактора с подсветкой синтаксиса.

На свете феньки есть такие, брат Горацио, которых лохи просто не секут. (Шекспир, «Гамлет», вольный перевод)


Оффлайн
wannabebrucelee

А как free pascal установить? Просто через поиски выдаёт на лазарус в основном и на ссылки, где я мало чё понимаю. И блокнот с подстветкой синстаксиса как установить? Пожалуйста,  направьте на путь истинный.


Оффлайн
Protopopulus

Синтаксис подсвечивается в стандартном gedit.
Установить — sudo apt-get install fpc (в терминале)

Если ты владеешь знаниями, то и знания владеют тобой. (с) Protopopulus


Оффлайн
wannabebrucelee

rm -rf ~/fpcinstall
mkdir ~/fpcinstall
cd ~/fpcinstall
wget ftp://ftp.chg.ru/pub/lang/pascal/fpc/dist/2.4.0/i386-linux/deb/*.deb
dpkg-scanpackages ./ | gzip -c9 > Packages.gz
grep «deb file:///$HOME/fpcinstall/ /» /etc/apt/sources.list || sudo echo «deb file:///$HOME/fpcinstall/ /» >> /etc/apt/sources.list
sudo apt-get update
sudo apt-get install fpc

Я вот чё в нете ща нашёл, и установил, это нормально? Я ничё не наворочил?
Ну вот я пишу код в gedit  а потом куда и что мне сохранять? в каком формате? И как выводить результат работы прграммы?


Оффлайн
Protopopulus

Нормально все установил, молодец.

А по поводу написания… Сохраняешь в любой текстовый (plain-text) документ, можешь даже с расширением pas. А потом с терминала компилякаешь его:
fpc -TLINUX /path/to_document
Потом запускаешь:
/path_to/program
Программа будет иметь название исходного файла минус расширение .pas и лежать в той же директории, что и исходник.

Если ты владеешь знаниями, то и знания владеют тобой. (с) Protopopulus


Оффлайн
wannabebrucelee

спасибо, пока вроде всё работает, ну я ещё обращусь, если чё)


  • Печать

Страницы: [1]   Вверх

Topic: [SOLVED]»Unit expected but Program found!?» Whats wrong?  (Read 3352 times)

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 »


Logged

Amstrad Schneider CPC 6128
Wind XP / 7 / 10


For me, it compiles ok, as a «simple program» project.
Lazarus 2.0.4, Windows 8


Logged

To err is human, but to really mess things up, you need a computer.


There seems a  big problem?!

If I compile it in freepascal folder..it seems to wordk..If i say
save to.c:ToolsPascaltest.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 »


Logged

Amstrad Schneider CPC 6128
Wind XP / 7 / 10


Why isn’t allowed the
 Program Windows;

If I do this , this happens

If i reanem Windows in xyz, it works


Logged

Amstrad Schneider CPC 6128
Wind XP / 7 / 10


What happens if you try to compile your file using the fpc compiler invoked at the command line?

MarkMLl


Logged

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


(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!


Logged


Yes, but My is names Windows1 not Windows


Logged

Amstrad Schneider CPC 6128
Wind XP / 7 / 10


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?


Logged

Amstrad Schneider CPC 6128
Wind XP / 7 / 10



Logged

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


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 »


Logged

Amstrad Schneider CPC 6128
Wind XP / 7 / 10


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 »


Logged


I will try it later on an other Laptop


Logged

Amstrad Schneider CPC 6128
Wind XP / 7 / 10


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.

  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:

  1. {$mode objfpc}

  2. begin

  3. end.

« Last Edit: October 31, 2019, 07:26:06 pm by Thaddy »


Logged

«Looks» OK, doesn’t mean it is IS OK.



Logged


<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?


Logged

Amstrad Schneider CPC 6128
Wind XP / 7 / 10


Иван Шихалев писал(а):Судя по всему, пути поиска не указаны, или кривые. Что в fpc.cfg?

#
# Example fpc.cfg for Free Pascal Compiler
#

# ———————-
# Defines (preprocessor)
# ———————-

#
# nested #IFNDEF, #IFDEF, #ENDIF, #ELSE, #DEFINE, #UNDEF are allowed
#
# -d is the same as #DEFINE
# -u is the same as #UNDEF
#

#
# Some examples (for switches see below, and the -? helppages)
#
# Try compiling with the -dRELEASE or -dDEBUG on the commandline
#

# For a release compile with optimizes and strip debuginfo
#IFDEF RELEASE
-O2
-Xs
#WRITE Compiling Release Version
#ENDIF

# For a debug version compile with debuginfo and all codegeneration checks on
#IFDEF DEBUG
-g
-Crtoi
#WRITE Compiling Debug Version
#ENDIF

# set binutils prefix

#IFNDEF CPUI386
#IFNDEF CPUAMD64
#DEFINE NEEDCROSSBINUTILS
#ENDIF
#ENDIF

#IFNDEF linux
#DEFINE NEEDCROSSBINUTILS
#ENDIF

#IFDEF FPC_CROSSCOMPILING
#IFDEF NEEDCROSSBINUTILS
-XP$fpctarget-
#ENDIF NEEDCROSSBINUTILS
#ENDIF

# assembling
#ifdef darwin
# use pipes instead of temporary files for assembling
-ap
#endif

# —————-
# Parsing switches
# —————-

# Pascal language mode
# -Mfpc free pascal dialect (default)
# -Mobjfpc switch some Delphi 2 extensions on
# -Mdelphi tries to be Delphi compatible
# -Mtp tries to be TP/BP 7.0 compatible
# -Mgpc tries to be gpc compatible
# -Mmacpas tries to be compatible to the macintosh pascal dialects
#
# Turn on Object Pascal extensions by default
#-Mobjfpc

# Assembler reader mode
# -Rdefault use default assembler
# -Ratt read AT&T style assembler
# -Rintel read Intel style assembler
#
# All assembler blocks are AT&T styled by default
#-Ratt

# Semantic checking
# -S2 same as -Mobjfpc
# -Sc supports operators like C (*=,+=,/= and -=)
# -Sa include assertion code.
# -Sd same as -Mdelphi
# -Se<x> error options. <x> is a combination of the following:
# <n> : compiler stops after the <n> errors (default is 1)
# w : compiler stops also after warnings
# n : compiler stops also after notes
# h : compiler stops also after hints
# -Sg allow LABEL and GOTO
# -Sh Use ansistrings
# -Si support C++ styled INLINE
# -Sk load fpcylix unit
# -SI<x> set interface style to <x>
# -SIcom COM compatible interface (default)
# -SIcorba CORBA compatible interface
# -Sm support macros like C (global)
# -So same as -Mtp
# -Sp same as -Mgpc
# -Ss constructor name must be init (destructor must be done)
# -St allow static keyword in objects
# -Sx enable exception keywords (default in Delphi/ObjFPC modes)
#
# Allow goto, inline, C-operators, C-vars
-Sgic

# —————
# Code generation
# —————

# Uncomment the next line if you always want static/dynamic units by default
# (can be overruled with -CD, -CS at the commandline)
#-CS
#-CD

# Set the default heapsize to 8Mb
#-Ch8000000

# Set default codegeneration checks (iocheck, overflow, range, stack)
#-Ci
#-Co
#-Cr
#-Ct

# Optimizer switches
# -Os generate smaller code
# -O1 level 1 optimizations (quick optimizations, debuggable)
# -O2 level 2 optimizations (-O1 + optimizations which make debugging more difficult)
# -O3 level 3 optimizations (-O2 + optimizations which also may make the program slower rather than faster)
# -Op<x> set target cpu for optimizing, see fpc -i for possible values
#
# See «fpc -i» also for more fine-grained control over which optimizations
# to perform

#ifdef darwin
#ifdef cpui386
-Cppentiumm
-Oppentiumm
#endif
#endif

# ————————
# Set Filenames and Paths
# ————————

# Slashes are also allowed under dos

# path to the messagefile, not necessary anymore but can be used to override
# the default language
#-Fr/usr/lib/fpc/$fpcversion/msg/errore.msg
#-Fr/usr/lib/fpc/$fpcversion/msg/errorn.msg

#IFDEF FPCAPACHE_1_3
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd13/
#ELSE
#IFDEF FPCAPACHE_2_0
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd20
#ELSE
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd22
#ENDIF
#ENDIF

# searchpath for units and other system dependent things
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
#-Fu~/fpc/packages/base/*/units/;~/fpc/fcl/units/;~/fpc/rtl/units/

# searchpath for libraries
#ifdef cpux86_64
-Fl/usr/lib/gcc/x86_64-linux-gnu/4.4.5
#endif

#ifdef cpui386
-Fl/usr/lib/gcc/x86_64-linux-gnu/4.4.5
#endif
#-Fl/pp/lib
#-Fl/lib;/usr/lib

# ————-
# Linking
# ————-

# generate always debugging information for GDB (slows down the compiling
# process)
# -gc generate checks for pointers
# -gd use dbx
# -gg use gsym
# -gh use heap trace unit (for memory leak debugging)
# -gl use line info unit to show more info for backtraces
# -gv generates programs tracable with valgrind
# -gw generate dwarf debugging info
#
# Enable debuginfo and use the line info unit by default
#-gl

# always pass an option to the linker
#-k-s

# Always strip debuginfo from the executable
-Xs

# ————-
# Miscellaneous
# ————-

# Write always a nice FPC logo ;)
-l

# Verbosity
# e : Show errors (default) d : Show debug info
# w : Show warnings u : Show unit info
# n : Show notes t : Show tried/used files
# h : Show hints c : Show conditionals
# i : Show general info d : Show debug info
# l : Show linenumbers r : Rhide/GCC compatibility mode
# a : Show everything x : Executable info (Win32 only)
# b : Write file names messages with full path
# v : write fpcdebug.txt with p : Write tree.log with parse tree
# lots of debugging info
#
# Display Info, Warnings and Notes
-viwn
# If you don’t want so much verbosity use
#-vw

#
# That’s all folks
#

На чтение 2 мин. Просмотров 23 Опубликовано 15.12.2019

readln (‘p’);
чтение строки — это шикарно

writeln (‘Найти площадь прямоугольника’);
вывели текст после — логика на высоте

p=h*v;
плевать, что считали, правда h и v — не определены

h=20;
v=30;
о да, логика та же, надо определить h,v

can any one fix this?

write(‘Enter a selection(10,20,30,40):’);

writeln(’10 was selected’);

writeln(’20 was selected’);

writeln(’30 was selected’);

writeln(’40 was selected’);

writeln(‘something else was selected’);

Содержание

  1. 5 Answers
  2. Primary tabs
  3. Forums:

5 Answers

I don’t know any Pascal, but isn’t the problem obvious? Read your own title: you have a syntax error where you have accidentally used a fullstop where you should have used a semicolon. Look at the last line of your code. I assume you should have used a semicolon instead of a full stop to get:

Also, syntax errors would be less frequent if you used a code editor which had support for syntax highlighting so it would be more obvious where the syntax of your code is incorrect.

You have too few ends. The case-statement contains a number of items each wrapped in their own begin-end pair, the penultimate end is the end of one such pair. The last end in your code is the end that matches the start of the case-statement.

The compiler is expecting to see and end that matches the begin that comprises the body of the program, but it encounters a . instead.

So amazed that I found this topic already answered! Its like you’ve read my thoughts!

I was wondering the same thing too yesterday

Primary tabs

Forums:

При создании программы на Паскаль или Делфи может возникать такая ошибка:

unit1.pas(1,1) Fatal: Syntax error, «UNIT» expected but «PROGRAM» found

возникает для программы в lazarus delphi в случае, если вы используете неверный для консольного приложения тип проекта.

stkapler

0 / 0 / 0

Регистрация: 07.02.2018

Сообщений: 19

1

07.02.2018, 04:52. Показов 22776. Ответов 14

Метки delphi, lazarus, pascal (Все метки)


звучит задание: создай программу, в которой можно преподнести введенное пользователем число к указанному степеню.

покапавшись на всяких форумах и тп, написал код. вроде бы все ок. но при компиляции выдает ошибку в 41 строке unit1.pas(42,17) Fatal: Syntax error, «;» expected but «.» found

ниже код:

Delphi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
unit Unit1;
 
{$mode objfpc}{$H+}
 
interface
 
uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
 
type
 
  { TForm1 }
 
  TForm1 = class(TForm)
    Button1: TButton;
    E1: TEdit;
    E2: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;
 
var
  Form1: TForm1;
  x, n, y: extended;
 
implementation
              function Power(const Base, Exponent: Extended): Extended;
{$R *.lfm}
 
{ TForm1 }
 
procedure TForm1.Button1Click(Sender: TObject);
begin;
   x:=strtofloat(e1.text);
   n:=strtofloat(e2.text);
   y:=Power(n, x);
   label2.caption:=floattostrf(s, ffFixed, 5,2);
end;
 
end.

ps. уже сам нашел несколько ошибок, но все равно проблема осталась

Добавлено через 8 минут
*СТРОКА 37, А НЕ 41

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



Programming

Эксперт

94731 / 64177 / 26122

Регистрация: 12.04.2006

Сообщений: 116,782

07.02.2018, 04:52

Ответы с готовыми решениями:

Ошибка «project1.lpr(35,0) Fatal: Syntax error, «BEGIN» expected but «end of file» found»
type
tarray= array of integer;
var
a:tarray;
m,s,k:integer;
procedure…

Ошибка: project1.lpr(1,1) Fatal: Syntax error, «BEGIN» expected but «end of file» found
project1.lpr(1,1) Fatal: Syntax error, &quot;BEGIN&quot; expected but &quot;end of file&quot; found
выдает эту ошибку…

Ошибка: Fatal: Syntax error, «;» expected but «identifier Mas» found.
Где здесь синтаксическая ошибка( &quot;mas:=A2;&quot; )?

procedure TForm1.Button1Click(Sender: TObject);

Ошибка Fatal: Syntax error, «;» expected but «is» found
Не могу нигде прописать часть кода вот эт type tproc = procedure is…

14

Джоуи

1073 / 635 / 240

Регистрация: 05.05.2015

Сообщений: 3,546

Записей в блоге: 2

07.02.2018, 05:48

2

Цитата
Сообщение от stkapler
Посмотреть сообщение

implementation function Power(const Base, Exponent: Extended): Extended;

Директива implementation означает раздел реализации, а не описания. Вы не реализовали функцию Power, а просто ее описали (нету begin end). Кстати, переименуйте как-нибудь, а то функция Power уже есть в паскале



0



Модератор

8255 / 5477 / 2249

Регистрация: 21.01.2014

Сообщений: 23,578

Записей в блоге: 3

07.02.2018, 06:04

3

Цитата
Сообщение от stkapler
Посмотреть сообщение

НЕ ЗНАЮ ЧТО ДЕЛАТЬ!

 Комментарий модератора 
1. Создавать темы в нужном разделе
2. Создавать темы с осмысленным названием
3. Не дублировать свои темы!!!

Это официальное предупреждение: Ваши действия — это нарушение правил форума, а именно пп 4.2, 5.4 и 5.5

3. В секции uses подключить модуль Math
4. Удалить к чертовой матери строку 32
5. В строке 42 заменить переменную внутри FloatToStr(…) Вы присвоили результат возведения в степень в переменную Y, а там у Вас какая-то, не пойми откуда взявшаяся, S…



0



stkapler

0 / 0 / 0

Регистрация: 07.02.2018

Сообщений: 19

07.02.2018, 12:22

 [ТС]

4

сделал все как вы сказали
но теперь выдает ошибку в сроке 39 и 40

unit1.pas(39,25) Error: Incompatible type for arg no. 1: Got «TTranslateString», expected «Int64»

unit1.pas(39,25) Error: Incompatible type for arg no. 1: Got «TTranslateString», expected «Int64»

сами строки

Pascal
1
2
   x:=FloatToStr(E1.Text);
   n:=FloatToStr(E2.Text);

у меня есть готовый ответ на это задание, даже 2. но все таки хочу найти решение самостоятельно, пусть даже при помощи форумчан)



0



Модератор

8255 / 5477 / 2249

Регистрация: 21.01.2014

Сообщений: 23,578

Записей в блоге: 3

07.02.2018, 12:35

5

stkapler, Вы строку переводите в число, поэтому функция StrToFloat()

Добавлено через 7 минут
В стартовом посте все правильно ведь было написано!



0



0 / 0 / 0

Регистрация: 07.02.2018

Сообщений: 19

07.02.2018, 12:36

 [ТС]

6

все хорошо, спасибо! проект компилируется и запускается

НО!! при вводе чисел и после нажатия кнопки — ничего не происходит. а должен быть результат

visible включен. шрифт норм, цвет отличный от фона. ничего не понимаю



0



Модератор

8255 / 5477 / 2249

Регистрация: 21.01.2014

Сообщений: 23,578

Записей в блоге: 3

07.02.2018, 12:41

7

А Вы этот обработчик создавали, или так просто написали?



0



0 / 0 / 0

Регистрация: 07.02.2018

Сообщений: 19

07.02.2018, 12:43

 [ТС]

8

нет, не создавал
но в планах для красивого оформления программы это есть
но сейчас просто функционал кода
и результат не отображается



0



Модератор

8255 / 5477 / 2249

Регистрация: 21.01.2014

Сообщений: 23,578

Записей в блоге: 3

07.02.2018, 14:48

9

Лучший ответ Сообщение было отмечено ZX Spectrum-128 как решение

Решение

Не по теме:

Цитата
Сообщение от D1973
Посмотреть сообщение

А Вы этот обработчик создавали

Цитата
Сообщение от stkapler
Посмотреть сообщение

нет, не создавал но в планах для красивого оформления программы это есть

:scratch:

stkapler, возьмите любую книжку по самым-самым азам создания программ в среде Delphi/Lazarus и обязательно прочтите ее… Ну или программирование бросайте прямо сейчас…
Все, что от Вас требовалось — это положить на форму кнопку, сделать на этой кнопке двойной клик и в получившейся заготовке обработчика события написать код.



0



0 / 0 / 0

Регистрация: 07.02.2018

Сообщений: 19

07.02.2018, 19:11

 [ТС]

10

спасибо, теперь все ок!
мне тут пол года учиться осталось, до сдам эти проекты — и буду гулять
вообще не пойму, зачем в 2018 дают учить паскаль
но за помощь — огромное спасибо!



0



Hretgir

07.02.2018, 20:01

Не по теме:

Цитата
Сообщение от stkapler
Посмотреть сообщение

зачем в 2018 дают учить паскаль

действительно, ребята учатся на начальников Била Гейтса, а их Паскаль учить заставляют, маразм да и только.



0



0 / 0 / 0

Регистрация: 07.02.2018

Сообщений: 19

07.02.2018, 20:08

 [ТС]

12

орнул. ну считайте что у меня узкое мировоззрение, ваше право
но смысла в этом я действительно не вижу. мое мнение и никому его не прививаю



0



Hretgir

07.02.2018, 20:37

Не по теме:

а что-бы вы хотели учить в 2018? просто интересно…
вот я-бы хотел учить нейросети, а получается что по факту мне нужен паскаль, на настоящий момент.
хотя можете не отвечать, я только мешаю.



0



stkapler

07.02.2018, 20:58

 [ТС]

Не по теме:

я себе сейчас спокойно учу видеомонтаж в свое свободное время, но учить паскаль — навязывает школьная программа



0



Cyborg Drone

08.02.2018, 09:25


    Ошибка «Fatal: Syntax error, «;» expected but «.» found»

Не по теме:

Да не спорьте. Не нужно знать язык программирования — значит, не нужно. Личное дело каждого. С другой стороны, те, кто всерьёз занимается программированием, как правило, знает несколько языков программирования, и выучить ещё один, как правило, никакая не проблема.



0



IT_Exp

Эксперт

87844 / 49110 / 22898

Регистрация: 17.06.2006

Сообщений: 92,604

08.02.2018, 09:25

Fatal: Syntax error, «BEGIN» expected but «end of file» found
Доброго времени суток! Вот простой код, который, по идее, находит корни квадратного уравнения….

Unit1.pas(41,5) Fatal: Syntax error, «;» expected but «identifier Y» found
Привет всем.Сделал программу,вроде как должна работать,не пойму в чем проблема(программа вся…

Fatal: Syntax error, «BEGIN» expected but «identifier BITMAP» found
Добрый день! пишу программу по методичке, выдает вот такие ошибки:
unit1.pas(78,1) Fatal: Syntax…

Unit1.pas(66,4) Fatal: Syntax error, «;» expected but «.» found
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils, FileUtil, Forms,…

Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:

15

Понравилась статья? Поделить с друзьями:
  • Syntax error unexpected token public
  • Sysprep exe неустранимая ошибка
  • Sysprep error 0x80073cf2
  • Sysprep error 0x0f0070
  • Syslinux edd load error boot error