Tag Archives: freepascal

Fixing curlpas so it would compile and install in latest Lazarus/FreePascal

What is curlpas? (Taken from the official web)

CurlPas is a Delphi / Kylix / FreePascal binding and component wrapper for libcurl .

Curlpas had so many features that other internet LCL didn’t have. Such as: multi-platform, non-blocking, proxy support, SSL support, byte ranges, multiple asynchronous transfers. The most exiting part for me is that curlpas make it easier for me to understand internet/network programming (I use curl a lot in my PHP projects).

The problem is that curlpas is so old (dated 2005) and haven’t updated to reflect latest change in Lazarus IDE and FPC. So, when you try to compile it, you’ll get a lot of error messages mostly about PChar, AnsiString, WideString and Pointer. (I forgot the exact error messages).

In order to fix those errors, you have to:

  • edit file curl_h.pas line #29, from this

into this

  • edit file ocurluse.inc line #6 until #9 from this

into this (notice that I only move the H+ directive)

  • edit file ocurlcb2.inc on line #30 from

into this:

  • and still in ocurlcb2.inc but on line #93 from

into this:

  • and the last one to edit is ocurlini.inc line #125, from:

into this:

  • save all, compile and install on your Lazarus IDE, cURL should be shown in Lazarus component palette named “Internet”

above steps had been tested on Lazarus 1.1, FPC 2.7.1 on Ubuntu Linux 12.04 and Windows 7

Basic Matrix operation in Lazarus/FreePascal

Well.. This is my first post about FreePascal (FPC)/Lazarus. I’ve been asked to create a simulation for artificial neural-network using backpropagation without using Matlab. So, I decided to use FreePascal/Lazarus to create it. Why? Because it’s challenging.. 😀

First problem that I need to overcome is how to mimic matrix arithmetic in FreePascal just like in Matlab. So, after some searching, I found satisfactory library called DynMatrix.

Download dynmatrix.zip file from here: http://paginas.fe.up.pt/~paco/pmwiki/index.php?n=DynMatrix.DynMatrix

Extract two files inside the archive, you’ll need only: dynmatrixutils.pas and dynmatrix.pas.

Use these two files in your project/form, example:

Now, for the example usage:
Declare a matrix variables:

Init a matrix into all zeros with 4 rows and 3 cols:

Setting a value for an element in matrix:

Getting the value of an element:

Matrix addition, subtraction, multiplication and matrix power:

Matrix transpose, inverse and convolution

Converting string to matrix:

Creating “eye” matrix:

Does this library also works on Delphi? Although I have Delphi, I haven’t tried it. So, no idea, but I’ve been looking at the source code and it seems it is OK to use it on Delphi Pascal. The dependecies is only on SysUtils, math and Classes