Write Commandline Pascal Programs in Lazarus
Вставка
- Опубліковано 3 лип 2024
- There’s nothing quite so satisfyingly retro as a program that runs from the system prompt. Using the Lazarus IDE with the Free Pascal compiler, it’s quite easy to create commandline programs. In this video I explain how I converted my form-based adventure game to one that runs from a prompt.
LAZARUS / OBJECT PASCAL PROGRAMMING PLAYLIST
This series explains cross-platform programming using Lazarus and Free Pascal on Windows and the Raspberry Pi OS. It will cover everything from procedural Pascal to object orientation with Object Pascal. The Pascal language used is also closely compatible with Object Pascal for Delphi. Be sure to bookmark the series Playlist: • Cross-Platform Program...
WRITE AN ADVENTURE GAME
The game here is very simple but if you want to create a complete adventure game, I explain all the essential techniques in a different UA-cam series which you can find here:
• Complete Course in Adv...
Huw Collingbourne is author of The Little Book Of Adventure Game Programming In C#. Available from:
* Amazon.com amzn.to/33M6sQ4
* Amazon.co.uk amzn.to/2YtaBrj
And also, The Little Java Book Of Adventure Game Programming. Available from:
* Amazon (US) amzn.to/3gizI93
* Amazon (UK) amzn.to/3mydF0e
PROGRAMMING OBJECT PASCAL
Huw Collingbourne is author of The Little Book Of Delphi (Object Pascal) Programming. Available from:
* Amazon.com www.amazon.com/Little-Book-De...
* Amazon.co.uk www.amazon.co.uk/Little-Book-...
Download Lazarus and Free Pascal: www.lazarus-ide.org/
I have always dreamed of writing a console program that connects to the database with the sqlDB tools of the Lazarus environment
Give it a try. Sounds like a good project.
@@LearnWithHuw
program connexion_consol_bdd;
{$mode objfpc}{$H+}
uses Classes, SysUtils, IBConnection, SQLDBLib, SQLDB, DB;
var
bdd : TIBConnection;
lib_bdd : TSQLDBLibraryLoader;
SQLQuery : TSQLQuery;
SQLTransaction: TSQLTransaction;
begin
bdd :=TIBConnection.Create(nil);
lib_bdd :=TSQLDBLibraryLoader.Create(nil);
SQLQuery :=TSQLQuery.Create(nil);
SQLTransaction:=TSQLTransaction.Create(nil);
bdd.databasename:= '/exem.fdb';
bdd.hostname := '192.168.56.7';
bdd.port := 3050;
bdd.username := 'sysdba';
bdd.password := '8246951,;:!';
bdd.Transaction := SQLTransaction;
lib_bdd.LibraryName:='Firebird';
lib_bdd.LibraryName:='/opt/firebird/lib/libfbclient.so.4.0.3';
SQLQuery.database:= bdd;
SQLQuery.sql.add(' select * from liste ');
SQLQuery.Transaction := SQLTransaction;
SQLTransaction.database:=bdd;
lib_bdd.Enabled:=true;
bdd.Connected:=true;
SQLQuery.Active:=true;
SQLTransaction.Active:=true;
write(SQLQuery.FieldByName('nom').AsString);
readln;
end.
=====================================
the program compiles but it sends me an error that the database is not recognized why what should I do?
=====================================
An unhandled exception occurred at $000000000048AE7A:
EDatabaseError: : Invalid connection type : ""
$000000000048AE7A
$000000000047FA85
program connexion_consol_bdd;
{$mode objfpc}{$H+}
uses Classes, SysUtils, IBConnection, SQLDBLib, SQLDB, DB;
var
bdd : TIBConnection;
lib_bdd : TSQLDBLibraryLoader;
SQLQuery : TSQLQuery;
SQLTransaction: TSQLTransaction;
begin
bdd :=TIBConnection.Create(nil);
lib_bdd :=TSQLDBLibraryLoader.Create(nil);
SQLQuery :=TSQLQuery.Create(nil);
SQLTransaction:=TSQLTransaction.Create(nil);
bdd.databasename:= '/exem.fdb';
bdd.hostname := '192.168.56.7';
bdd.port := 3050;
bdd.username := 'sysdba';
bdd.password := '8246951,;:!';
bdd.Transaction := SQLTransaction;
lib_bdd.LibraryName:='Firebird';
lib_bdd.LibraryName:='/opt/firebird/lib/libfbclient.so.4.0.3';
SQLQuery.database:= bdd;
SQLQuery.sql.add(' select * from liste ');
SQLQuery.Transaction := SQLTransaction;
SQLTransaction.database:=bdd;
lib_bdd.Enabled:=true;
bdd.Connected:=true;
SQLQuery.Active:=true;
SQLTransaction.Active:=true;
write(SQLQuery.FieldByName('nom').AsString);
readln;
end.
===========================================
An unhandled exception occurred at $000000000048AE7A:
EDatabaseError: : Invalid connection type : ""
$000000000048AE7A
$000000000047FA85
===========================================
the compilation passes but during execution, the database is not recognized why? please