[fpc-pascal] Hello, new Pascal programmer. had a question!

James Richters james.richters at productionautomation.net
Wed Sep 1 02:40:25 CEST 2021


>I guess I should just use lazarus and learn the GUI Tools. I was having a problem when i was following the one of the books on the FP book wiki
> , where i went to compile my program, and the IDE threw an error about an .o file not found. 
 
As others have mentioned, you can write console programs with Lazarus,  The advice to use Lazarus is good advice, you can write both Console and GUI applications with it.
 
As far as the .o file not found, 
Try File > New > Project > Simple Program
You can put something simple like:
 
Writeln('Hello World');
Readln;
 
Between the Begin and End.
 
Then immediately try to compile it… 
If you get an error about a .o file not found, then check your directories with Tools > Options > Files    Maybe one of the directories is not in the right place.
 
Or just try to re-install it.
 
Make sure to follow the installation instructions and pay close attention to details, as I recall Lazarus needs to know where FPC is installed, you can’t just run the setup program and click ok ok ok to everything until it’s done.  I think I had a similar problem with it once, and it was because it asked me to set the path to FPC and I didn’t do it right or something.. and it was the kind of thing that it only asked for once… either during install or the first time I ran it, and if you don’t answer it accurately, nothing works right.
 
There are times you just don't want or need a program to do anything other than sequential processing, and for those things Console applications are just fine.. There is defiantly a place for Console Applications.
And there are times when having an event driven program is better.. it really depends on the application.  Personally I find that the easiest way to learn a new programming language, is to have a desired task to perform and figure out how to get it done..  The first step should be completing this sentence, ‘I want to write a program to _____________________’  .  Once you have a goal, then you can figure out how will the user interact with this program… when you figure that out, you will know if you want a console application or a GUI application.   If the user doesn’t need to interact with the program a lot, say you wan to just open a file and sort the contents and write out a sorted file, then a Console Program is fine, and probably less complicated.  If on the other hand the user needs to constantly interact with the program, than a GUI program is probably the best approach. 
 
I primarily use the Free Pascal IDE.  It's a little clunky for editing, so I use Notepad ++ for editing, but then I always use the IDE for compiling.  If I have an error it is pretty clear what the error is and it highlights it for me, and then I normally just fix it with the Free Pascal IDE.  The reason I use the FPC IDE is because I've tried several times to compile my largest projects with Lazarus and they won't even compile there, and it seemed complicated to get them to work...  my projects have a lot of units, some units are {$mode TP} others are {$mode FPC} I have very large portions of code that came straight from Turbo Pascal, and I'm not sure why entire projects with all their units compile with no problem with the FPC IDE and Lazarus produces error after error..... for code that works fine with the FPC IDE.  Maybe I have settings in the FPC IDE that makes everything work, that I don’t have in Lazarus.  I’ve tried a few times to get it to work but while Options > Compiler is easy to find in the FPC IDE, I have no idea where the corresponding settings are in Lazarus.  I’ve tried looking under Tools > Options in Lazarus, and sure the directories are there, but not compiler options.   So now I have very involved programs with close to a hundred thousand lines of code, that won’t compile on Lazarus, so I keep using the FPC IDE.
 
There have ben occasions where I wanted to use a unit that was made for Lazarus, but not FPC, and having this situations where I have huge projects that won’t compile in Lazarus but work fine with the FPC IDE has required me to work around using Lazarus units… unfortunately it’s been easier to do that than to fix all the issues preventing me from compiling on Lazarus.
 
But… since you have zero lines of code… perhaps starting with Lazarus and just write simple console applications with that would be the best advice, because when your projects get larger and you decide maybe using some Lazarus units might be a good idea, then you won’t have the compatibility issues that I have.
 
James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20210831/d9d227f0/attachment-0001.htm>


More information about the fpc-pascal mailing list