Author Topic: Pascal  (Read 6478 times)

Tomaaz

  • Guest
Pascal
« on: 21. November 2012, 01:39:15 »
Is it difficult for someone who knows BASIC, Lua and JavaScript to start with Pascal? How different is it? I think I learned it in the past but have forgotten everything totally. :) I'd like to try EGSL engine with Pascal.

cvirus

  • Regular Member
  • Jr. Member
  • *
  • Posts: 76
    • View Profile
Re: Pascal
« Reply #1 on: 21. November 2012, 11:03:49 »
I don't think that is hard to move to pascal, see a simple record witch is very used in games.
But cybermonkey is the best person to answer that.


Code: [Select]
program Cars;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes
{ you can add units after this };
type
TCar = record
ModelName: string;
Engine: Single;
ModelYear: Integer;
end;
var
Car: TCar;
begin
Write('Input car Model Name: ');
Readln(Car.ModelName);
Write('Input car Engine size: ');
Readln(Car.Engine);
Write('Input car Model year: ');
Readln(Car.ModelYear);
Writeln;
Writeln('Car information: ');
Writeln('Model Name : ', Car.ModelName);
Writeln('Engine size : ', Car.Engine);
Writeln('Model Year : ', Car.ModelYear);
Write('Press enter key to close..');
Readln;
end.

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 573
    • View Profile
    • Home of EGSL
Re: Pascal
« Reply #2 on: 21. November 2012, 11:49:36 »
If you know BASIC, Pascal is rather easy to learn. I learned Turbo Pascal in School but did not code for years. Then I did some programming in yabasic. After that I re-discovered Pascal. This time it was Freepascal. The only thing one has to take care of is the type safety of Pascal. All variables have to be declared before they are used the first time. See here: http://wiki.freepascal.org/Variables_and_Data_Types
BTW, if you want to use the egslengine with FPC I recommend not to use Lazarus. All pure Pascal programming is done with Geany by me.
Best regards,
Cybermonkey

Tomaaz

  • Guest
Re: Pascal
« Reply #3 on: 21. November 2012, 12:06:09 »
Declaring variables shouldn't be a problem. I did some coding in C, but, of course, I wouldn't call myself a C programmer. ;) I wasn't even thinking about Lazarus. The compiler is all I want to use. I will try and if I like it you can expect questions about Pascal and EGSL engine soon. ;)

Thanx!  :)

Tomaaz

  • Guest
Re: Pascal
« Reply #4 on: 21. November 2012, 17:35:01 »
Forget it. I don't like Pascal. I could even stand annoying begin...end blocks (curly brackets are much better solution) but := instead of = is too much for me. :)

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 573
    • View Profile
    • Home of EGSL
Re: Pascal
« Reply #5 on: 21. November 2012, 17:39:10 »
Hm, in C you've got = and ==, so no big difference.
Best regards,
Cybermonkey

Tomaaz

  • Guest
Re: Pascal
« Reply #6 on: 21. November 2012, 17:46:48 »
You can find '=' and '==' in many languages (probably all widely used today). Do you know other than Pascal languages that use ':=' and '='? I'm not saying that Pascal is bad language. I'm just afraid that constant switching between '=', '==' and ':=', '=' will be painful. ;)
« Last Edit: 21. November 2012, 17:49:04 by Tomaaz »

Bereb

  • Newcomer
  • *
  • Posts: 47
    • View Profile
Re: Pascal
« Reply #7 on: 24. November 2012, 14:13:08 »
I was fascinated by Pascal, as I was for Lisp too, for a long time, but these appear to me to be too complex languages (for my mind), so I left them at that : I prefer Basic(s), Logo, newLisp even though (because it's a very simple scripting Lisp/Scheme-like language) and Lua (because it's small but strong)  :) ... I'm just an amateur and I thank the ones who create programing or scripting languages within the reach of people like me  ;)
Regards, Bertrand :)
** Lubuntu 14.04 (Intel Celeron CPU 2.66GHz - 1280MiB) **

Tomaaz

  • Guest
Re: Pascal
« Reply #8 on: 04. December 2012, 17:30:18 »
I didn't give up yet and tried to use egslengine with Free Pascal under Linux. Finally I was successful, but several errors occurred and I have to edit egslengine source code.

1. I had to remove everything related to Haiku from the source code, because compiler was trying to load all the stuff for Haiku
2. I had to fix two IF/THEN blocks

Background() and rectangle() commands still don't work, but I can use, for example, openwindow(), clearscreen(), dot(), box(), line(), wait(), sync(). I'm pretty sure I'm doing something wrong (the compiler has hundreds options), so hopefully someone will help me to make it work properly.


Tomaaz

  • Guest
Re: Pascal
« Reply #9 on: 04. December 2012, 20:07:31 »
OK. There was something wrong with that file. I unpacked it once again and this time, there was no problem with IF/THEN blocks.  ??? It compiles with -Mdelphi option, but there is still this "Haiku" problem.

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 573
    • View Profile
    • Home of EGSL
Re: Pascal
« Reply #10 on: 04. December 2012, 21:21:01 »
Hm, weird. Works everything fine here. The Haiku stuff is only compiled if FPC detects Haiku ... Do you have the Vampyre Imaging Library added? Can you post the error output?
Best regards,
Cybermonkey

Tomaaz

  • Guest
Re: Pascal
« Reply #11 on: 04. December 2012, 21:26:24 »
Code: [Select]
fpc test.pas -MDelphi (w katalogu /home/tomek)
Free Pascal Compiler version 2.4.0-2ubuntu1.10.04 [2011/06/17] for i386
Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Linux for i386
Compiling test.pas
Compiling egslengine.pas
Fatal: Can't find unit ImagingSDL used by egslengine
Fatal: Compilation aborted
Kompilacja nie powiodła się
Error: /usr/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled)

ImagingSDL seems to be used only under Haiku, but I might be wrong, of course.

BTW Background() was my mistake and I've just realized that rectangle() is not implemented yet (right?).

EDIT: It might be problem with that library, but on the other hand, I'm using EGSL without any problem on this machine, so I assume everything is installed.
« Last Edit: 04. December 2012, 21:48:29 by Tomaaz »

Cybermonkey

  • Administrator
  • Hero Member
  • *****
  • Posts: 573
    • View Profile
    • Home of EGSL
Re: Pascal
« Reply #12 on: 04. December 2012, 22:10:50 »
Nope, ImagingSDL is not SDL_Image (which is used on Haiku). You have to downlaod the Vampyre Imaging Library here: http://imaginglib.sourceforge.net/
Oh, and I recommend to use FPC 2.6.0 ...
Best regards,
Cybermonkey

Tomaaz

  • Guest
Re: Pascal
« Reply #13 on: 04. December 2012, 22:16:51 »
Nope, ImagingSDL is not SDL_Image (which is used on Haiku). You have to downlaod the Vampyre Imaging Library here: http://imaginglib.sourceforge.net/

I did it, build it, but it doesn't work. :( Now I'm trying to install FreePascal 2.6.0...

Tomaaz

  • Guest
Re: Pascal
« Reply #14 on: 04. December 2012, 22:26:11 »
FreePascal has been installed, but where should I place this library?  ???

EDIT All I'm getting is:
Code: [Select]
fpc test.pas -MDelphi (w katalogu /home/tomek)
Free Pascal Compiler version 2.6.0 [2011/12/23] for i386
Copyright (c) 1993-2011 by Florian Klaempfl and others
Target OS: Linux for i386
Compiling test.pas
Compiling egslengine.pas
Fatal: Can't find unit ImagingSDL used by egslengine
Fatal: Compilation aborted
Kompilacja nie powiodła się
Error: /usr/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled)

:(
« Last Edit: 04. December 2012, 22:27:46 by Tomaaz »