Page 1 of 1

Lazarus Pascal – Move Items to Trash for Windows, Linux and macOS

Lazarus Pascal – Move Items to Trash for Windows, Linux and macOS

In this short article I’ll show how I implemented a cross platform (Windows, Linux, macOS) function for Lazarus Pascal to move files or directories to the TrashCan or Recycle Bin.

Since it took me some figuring out, I figured; why not write it down so others may benefit from this as well.
For your convenience: You can also download the Lazarus Pascal unit here, which holds the function for macOS, Linux and macOS.

MacOS – SMJobBless: Elevated Privileges in Lazarus Pascal

MacOS – SMJobBless: Elevated Privileges in Lazarus Pascal

As some of you know, I created ApplePi-Baker a while ago, and with a new version I wanted to get away from using command-line tools like “dd” and “diskutil“. To do this the right way I needed to know how to use SMJobBless, in order to get root access, a.k.a. elevated privileges, privileged helper tool, etc.

Back in the day, we could do this pretty easy in our application, simply by using opening, reading and writing data from/to disks as “files”, with relatively simple code in our applications. These days seem to be gone …

With all kinds of malware trying to “hack” us, companies like Apple and Microsoft keep making it increasingly more difficult to actually get admin (root) access straight from our application (not to mention the seemingly cumbersome signing of applications). Which is all good, just too bad that the now majority of the time I spend on developing an application involves adapting to these limitations, instead of doing the creative thinking towards what the application really is for.

Apple has created a poorly documented mechanism for this, referred to as “SMJobBless” or “Privileged Helper“, and focusses heavily on Objective C and Swift – neither of these I like, let alone working with XCode (yuk!) – I really prefer working in Pascal, and specifically in an awesome IDE provided by Lazarus Pascal.

So in this article, I’m documenting my own findings to get this working with Lazarus Pascal – which took a lot of work and testing.

Keep in mind – I’m definitely not an expert on this topic, and I tried to include as much of what I found out as possible. It appears no-one has done this with Lazarus Pascal yet, so please bear with me, and definitely feel free to post improvements and/or suggestions. I’m sure there may be better ways and I’m always open to improving things, including myself.

Lazarus Pascal – Custom Fonts for MacOS Applications

Lazarus Pascal – Custom Fonts for MacOS Applications

I’m not sure about other developers, but I occasionally like to use my own custom font for my Lazarus Pascal applications. Typically I do this so I have access to better icons and symbols available in my application, instead of semi blurry bitmap icons. If you use this the right way, your icons and symbols will look much better and will scale really great.

Usually, I use a TTF font for this which I generate at IcoMoon.
IcoMoon is an awesome website where you can compile your own TTF font (or SVG or PNG images of symbols) for use with your website (Tweaking4All uses it as well) or … in your applications.

Since there are plenty examples out there how to do this in Lazarus Pascal for Windows, here an article that shows you how to do this in Lazarus Pascal under macOS.

Lazarus Pascal – Retrieve Yahoo Weather Forecast

Lazarus Pascal – Retrieve Yahoo Weather Forecast

I like dabbling with Lazarus Pascal, a free IDE for developing Pascal programs for Windows, MacOS X and Linux, quite similar to Delphi.

One of my projects, would look great with a weather forecast, so I went an figured out how this works by accessing the Yahoo Weather API. This took me a little bit to figure out, but I’ve got it running now, even using https.
This week I decided to put it all in a small unit, so others can use it as well.

This unit only needs Synapse, which is free as well, and uses fcl-json, which comes with Lazarus.

Lazarus Pascal – Unit to Add or Remove Autorun items (Windows/MacOSX)

Lazarus Pascal – Unit to Add or Remove Autorun items (Windows/MacOSX)

When developing an application, sometimes it can be useful to offer the user a way to add this application to the LoginItems (Mac) or Autorun items (Windows), so that the application starts when MacOS X or Windows starts.

Since I have developed a couple applications for which this would be helpful, and as of lately even one for both platforms, I figured, why not place this in a unit so the code can be resused easily and quickly. Sharing the code would make life easier for others as well.

So here we are – feel free to post improvements – a unit that Adds, Removes and Checks if an application build with Lazarus Pascal, from the Loginitem/Autorun items.

Lazarus – How to add data to lists with AddObject

Lazarus – How to add data to lists with AddObject

Some components in Lazarus Pascal (and Delphi), especially the ones that have a list of strings, allow you to add additional data by linking an object to a string. The function “AddObject” is often used for this, but it’s also the most overlooked option.

With this option you can link (add) any kind of data to rows in your string list, allowing you to add additional (non visual) data.

In this short article, I’ll show you how you can work with these objects, which allow you to extend the data stored with your lists.

How to install Lazarus Pascal on Raspberry Pi 2 (Raspbian)

How to install Lazarus Pascal on Raspberry Pi 2 (Raspbian)

For those of you who have visited Tweaking4All more often, you might have noticed that I really like Lazarus Pascal. I use it to develop little freeware applications for multiple platforms (if possible), like for Windows, MacOS X and Linux.

So why not on a Raspberry Pi (Raspbian)? Lazarus allows Rapid Application Development in the good old Delphi style which would be ideal for a platform like the Raspberry Pi. Specially since the Raspberry Pi  2 Model B seems to be fast enough as well.

Now me and my brother-in-law (Jean-Pierre) are planning to build an Alarm system based on a Raspberry Pi 2, use a TouchScreen and plenty of sensor. Lazarus Pascal could be ideal for this purpose.

To my disappointment, it took me a lot of time to get Lazarus to run on my new Raspberry Pi 2 Model B … so that’s why I wrote this article, which is basically a compilation of a lot of steps that I found scattered all over the Internet.

Lazarus Free Pascal – Getting started with SQLite

Lazarus Free Pascal – Getting started with SQLite

Lazarus, a Free Pascal based free and open source cross-platform Delphi look-a-like software development tool, has been around for a while now and has become more and more mature. I actually used with it some of my experiments (Name My TV Series for example) to develop cross-platform applications.

In this article I’ll show you how to get started with the use of SQLite in your Lazarus applications. SQLite is an open source super compact embedded SQL engine which allows you to use an SQL database with your applications without the need to actually run a full-size SQL database server.

Some knowledge of SQL, Lazarus Pascal and databases is assumed.