Skip to content

Instantly share code, notes, and snippets.

@maksymx
Last active August 8, 2023 14:21
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maksymx/b98dff74f78fc52723983631b1e1c212 to your computer and use it in GitHub Desktop.
Save maksymx/b98dff74f78fc52723983631b1e1c212 to your computer and use it in GitHub Desktop.
Sublime Text build system for Pascal project

Pascal build system

  • Install Free Pascal
  • Install Sublime Text 3
  • Add Package control for Sublime Text
  • Install Pascal shippets: Ctrl+Shift+P-> type install-> type Pascal
  • Copy fpcbuild.bat to C:\\FPC\<version_number>\bin\i386-win32\
  • Create new build system: click menu Tools-> Build system-> New Build System and paste there code from PASCAL.sublime-build
  • Select this build system as default
  • Create new .pas file with code below and try new build Ctrl+B
program ProgramName;
procedure Main();
begin
	writeln('Hello world!');
	readln;
end;
begin
	Main();
end.

Enjoy!

@echo off
cd %~dp1
:: here we compiling our pascal code into 'null' file
fpc %~nx1 >null
:: if there are "Error:" in null file
>nul find "Error:" null && (
:: then print it to console and delete null file
type null
del null
) || (
:: otherwise run the compiled file in console
%~n1.exe
:: delete null file
del null
:: and run compiled file in command line window
start cmd /k %~n1.exe
)
{
"cmd": ["fpcbuild.bat", "$file"], "quiet": true
}
@heftiqk
Copy link

heftiqk commented Nov 17, 2020

Great work, only a little mistake. You have to rename the fcpbuild.bat to fpcbuild.bat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment