Author Topic: Pascal  (Read 13179 times)

Tomaaz

  • Guest
Pascal
« on: November 21, 2012, 12:39:15 am »
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

  • Guest
Re: Pascal
« Reply #1 on: November 21, 2012, 10:03:49 am »
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
  • *****
  • Posts: 0
Re: Pascal
« Reply #2 on: November 21, 2012, 10:49:36 am »
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.

Tomaaz

  • Guest
Re: Pascal
« Reply #3 on: November 21, 2012, 11:06:09 am »
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: November 21, 2012, 04:35:01 pm »
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
  • *****
  • Posts: 0
Re: Pascal
« Reply #5 on: November 21, 2012, 04:39:10 pm »
Hm, in C you've got = and ==, so no big difference.

Tomaaz

  • Guest
Re: Pascal
« Reply #6 on: November 21, 2012, 04:46:48 pm »
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: November 21, 2012, 04:49:04 pm by Tomaaz »

Bereb

  • Guest
Re: Pascal
« Reply #7 on: November 24, 2012, 01:13:08 pm »
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  ;)

Tomaaz

  • Guest
Re: Pascal
« Reply #8 on: December 04, 2012, 04:30:18 pm »
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: December 04, 2012, 07:07:31 pm »
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
  • *****
  • Posts: 0
Re: Pascal
« Reply #10 on: December 04, 2012, 08:21:01 pm »
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?

Tomaaz

  • Guest
Re: Pascal
« Reply #11 on: December 04, 2012, 08:26:24 pm »
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: December 04, 2012, 08:48:29 pm by Tomaaz »

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: Pascal
« Reply #12 on: December 04, 2012, 09:10:50 pm »
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 ...

Tomaaz

  • Guest
Re: Pascal
« Reply #13 on: December 04, 2012, 09:16:51 pm »
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: December 04, 2012, 09:26:11 pm »
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: December 04, 2012, 09:27:46 pm by Tomaaz »