28 November 2013

CodeSnip v3 Support Ending Soon

Given the small number of users of CodeSnip 3 out there, and the even smaller number of bug reports for it, I've decided to end support for this version at the end of 2013.

So, from January 2014, no more bugs will be fixed and no new features will be added. That means that any new Delphi compilers released after the end of this year will not be added to CodeSnip 3.

If you want to keep up to date please update to CodeSnip 4 now.

Sorry if that causes inconvenience, but this is a one-man developmet team and I need to spend my time developing v5!

13 October 2013

Old Code Snippets Database Online App Retired

After many year's service I've finally retired the old Code Snippets Database online viewer. It's been replaced by the new JavaScript driven version - "Take 2" - available at http://snippets.delphidabbler.com/.

The old app hadn't been able to display the newer snippets in the database for some time. However the killer blow was that some recent changes to the back-end database broke the app's ability to generate Pascal units.

Any bookmarks you have to the defunct application will now automatically redirect to "Take 2", so you won't be left staring at a 404 page.

Some links to the old application requested it to display a set of snippets that were named in the URL query string. So as not to break these links this type of URL will redirect to a special snippet listing script that will display the required snippets.

"Take 2" is an Ajax application the does much of its processing in the browser, so it should be quicker to use once all the data has loaded. It's also got a much cleaner and more modern user interface.

Although "Take 2" is still in beta it now has many features of the old app and adds some new ones. The only major feature still to implement is text searching, and that's on the to-do list.

Aplogies if the change is inconvenient. Please do give the new version a try - it may do what you want. Do ask if there are any features you would like to be added.

And, if you're a Windows user, don't forget that there's the CodeSnip code bank application that can load and display the snippets from the database.

16 September 2013

CodeSnip 5 - Proposed Feature Removal

I'm getting on with developing CodeSnip v5 and have been thinking of ditching some features that have struck me as particularly useless. These are all features I haven't used personally since CodeSnip v1.

They are:

  1. The Save Snippet option from the File menu.
  2. The related Copy Snippet option from the View menu.

Before I delete the features I'm looking for some feedback as to whether anyone uses them and can't live without them. If you want to keep them in v5 please get in touch. If I don't hear any howls of protest, the features are going to go!

Let me know what you think either by commenting or sending me a message via my website's contact page.

What follows is a little overview of what the features do.

All these options do is to generate something like the following and either put it on the clipboard or write it to file:

{
 * This code snippet was generated by DelphiDabbler CodeSnip Release 4.8.0 on
 * Mon, 16 Sep 2013 16:53:57 GMT. It is made available on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. The code is used
 * entirely at your own risk.
}

{
  Required unit(s):
    SysUtils
}

function DateQuarterEnd(const D: TDateTime): TDateTime;
  {Gets the date of the last day of the quarter containing a given date.}
var
  Year, Month, Day, Quarter: Word;
begin
  SysUtils.DecodeDate(D, Year, Month, Day);
  Quarter := 4 - ((12 - Month) div 3);
  // get 1st day of following quarter
  Month := 0;
  SysUtils.IncAMonth(Year, Month, Day, Quarter * 3 + 1);
  // required date is day before 1st day of following quarter
  Result := SysUtils.EncodeDate(Year, Month, 1) - 1.0;
end;

There's also the Edit | Copy Source Code option that just put the actual snippet source on the clipboard:

function DateQuarterEnd(const D: TDateTime): TDateTime;
var
  Year, Month, Day, Quarter: Word;
begin
  SysUtils.DecodeDate(D, Year, Month, Day);
  Quarter := 4 - ((12 - Month) div 3);
  // get 1st day of following quarter
  Month := 0;
  SysUtils.IncAMonth(Year, Month, Day, Quarter * 3 + 1);
  // required date is day before 1st day of following quarter
  Result := SysUtils.EncodeDate(Year, Month, 1) - 1.0;
end;

So, all the first option adds is to list the dependencies in comments (which you can get in more details from the program's View | Dependencies menu option) and some disclaimer.

Over to you.

08 September 2013

Code Snippets Database - Final call for CodeSnip v1 & v2 users

At the end of December last year I blogged that new snippets added to the Code Snippets Database would no longer be visible when the database was viewed with CodeSnip v1 and v2.

Despite CodeSnip 1 and 2 being prevented from viewing new snippets any existing snippets continued to have bug fixes applied. But today that all changed and from now on the database is frozen with respect to these programs: the database will still be available for download, but it will never change.

Also from today any original v0 beta releases of CodeSnip will no longer be able to even download the database - tying to do so will generate an error.

If you're one of the few remaining users of these early CodeSnip versions please update.

BTW I'm not pulling support for these old version out of spite. It's just that the Code Snippets database is being overhauled and maintaining support for these old programs is no longer viable.

15 June 2013

DelphiDabbler.com is back

DelphiDabbler.com is now back up and running following the recent outage.

If you are a CodeSnip user, the automatic database updating service may have failed during the outage and you could have missed an update. If you want to check if there are any database updates available please check manually using the Database | Update From Web menu option. For info, the last update was on 14th June.

If you rely on CodeSnip's program update notification that too may also have failed. For info the latest version at the moment in v4.6.0. If you're running and earlier version and want to update you can download v4.6.0 from SourceForge.

14 June 2013

DelphiDabbler.com currently disabled

Just a quick note to say that my website, DelphiDabbler.com, has been disabled, for what reason I'm not sure - trying to resolve it.

Until I can get this sorted, if you're looking for CodeSnip program updates, please look on SourceForge (https://sourceforge.net/projects/codesnip/). CodeSnip database updates won't be available until the site is up again.

If you are wanting files from my Delphi Library, please check out the ddab-lib project on GoogleCode.

More news when I have it.

Update 2013/06/15 09:47 BST: Seems my web hosting company thinks I've not renewed the account although I have done. Waiting for them to sort it out.

Update 2013/06/15 10:30 BST: The site is now working again. At least my web host admits their mistakes and apologises!

13 May 2013

Class helper for updating a TActionList

On occasions I've wanted to provoke all actions in an action list to update themselves - when waiting for the application to update them when idle isn't soon enough.

I would have thought that TActionList would have a suitable method, but it doesn't seem to.

To save having to come up with the same hack over and again, I've started using this class helper:

type
  TActionListHelper = class helper for TCustomActionList
  public
    procedure Update;
  end;
...
procedure TActionListHelper.Update;
var
  Action: TContainedAction;
begin
  for Action in Self do
    Action.Update;
end;

You can now update all the actions in an action list by calling the Update that has been injected into any TActionList instance.

Seems to work so I thought I'd share it.

If you've got a better way, please comment.

03 May 2013

Starting work on CodeSnip v5

Just announcing that I'm about to start work on the next major update to CodeSnip, i.e. version 5.

So if you use CodeSnip 4 and have any new features you'd like to see in CodeSnip 5, now's the time to let me know. You can see the current requests, and make your own, using the Feature Request tickets on SourceForge. You can also up- or down- vote requests there.

I'm considering a radical overhaul of the way the program handles snippets - and will be trying to integrate the current read-only snippets downloaded from the Code Snippets Database with your own snippets more seemlessly.

The other main thrust will be the ability to more easily share snippets with others both directly and online.

If you think that's the right way to go please tell me, and suggest how you see it.

My aim is to get something working (a preview or a beta) by the year end the end of Q2, 2014. As ever, no promises! EDIT - timings have slipped. Why does everything always take longer than planned?!

And finally, anyone who wants to join the project will be welcome - just send me a message from my website's contact page.

Out of Memory with XE4

Time for a quick rant before breakfast!

Late last year I bought Delphi XE3 with the aim of using it instead of Delphi 2010 to work on release 5 of my CodeSnip program.

I was just about to start last week when Delphi XE4 was released, so I decided to get the £40 upgrade (without the iOS stuff) to that and use it instead of XE3.

So yesterday I did the first test compile of the current CodeSnip 4 code base. After fixing a few incompatibilities I got my first successful build. Only it wasn't. XE4 crashed with an out of memory error. The error happens if I do a normal compile. A full build works.

Here's the rub - even if I do a full Shift+F9 rebuild I still can't run the program in the IDE's debugger because attempting to run an already compiled program results in the out of memory error! Could it be dependancy checking that's causing the problem?

Well that's a £40 update fee up the spout. Not a happy bunny.

It gets worse. The problem still exists in XE3. So there's another £450 wasted.

And XE2's still got the same problem. At least I got that for free on the "old licenses" deal.

Seems that this is a well known problem with larger projects - see this item that's been on Embarcadero's Quality Central for some time. Pretty poor showing I think.

So, I've decided to move CodeSnip to Delphi XE for now - it's got some VCL features that I want to use that aren't in Delphi 2010.

In fairness (although I'm not feeling very fair!) XE4 works fine for compiling some smaller projects and its helping with testing code for the Code Snippets Database. That said I think it's reasonable that a not inexpensive tool labelled "Professional" should be able to cope with a 450 unit project, just like its great grandparent parents did!

18 April 2013

The SWAG Pascal Archive

Way back in 1997 the old SWAG archive of Pascal code was closed down. There have been a few attempts to resurrect it over the years, with a HTML version being released in 2003. Unfortunately some of the mirrors have now been closed down.

Never heard of SWAG? Well this is what the original authors said about it:

SWAG is a collection of source code and program examples for the PASCAL programming language. The material has been donated by various PASCAL programmers from around the world ... SWAG packets are available in 57 different categories covering EVERY aspect of the PASCAL language ... SWAG is intended to be a teaching and learning aid for users of the PASCAL language. Whether you are a beginner or experienced programmer, you'll find SWAG to be an invaluable source of ideas and information.

After some discussion with a couple of Delphi & Pascal coders it would seem there's still some interest in preserving the archive in the hope it might be useful to others.

Anyhow, whether it's useful or not, I've now mirrored SWAG on delphidabbler.com.

I decided to go a little further than simply mirroring the original HTML version of the arhive: there are three ways of accessing SWAG:

  1. I've created a jQuery based web application at swag.delphidabbler.com where you can view the archive by category.
  2. You can access SWAG from your own program and web sites using a REST API. For more info see the API Docs.
  3. You can just download the original HTML archive as a 7z file from http://swag.delphidabbler.com/download/webswag.7z (about 18Mb).

If you've time to check the web app I'd be grateful for comments. I do intend to add syntax highlighting, but that's about all unless anyone suggests anything else.

Finally, I'm currently working on adding a feature to my CodeSnip to enable it to import code from SWAG into its code bank.

18 February 2013

The two faces of SHR

Like Marek Mauder in his blog post from 2009, I have run into a problem because of the different implementations of the right shift operator (shr in Pascal) in different languages.

There I was happily translating some code from Java to Object Pascal when I encountered Java's >>> operator. A quick look at the Java docs tells me this is a logical right shift. No problem, just use shr. Next I found Java's >> operator. This time its an arithmetic (sign preserving) right shift. Problem - no Pascal equivalent, and since operation was on signed integers I couldn't just use shr because there's a bug waiting to happen should any of the integers go negative.

Marek (above) said that replacing

a >> 1

with

a div 2;

worked for him.

This is fine for a single bit shift, so I thought I would see if it scaled for shifts of more than one bit. I tried dividing by 2 to the power of the number of bits to shift:

function SAR(Value: LongInt; Shift: Byte): LongInt;
begin
  Shift := Shift and 31;
  if Shift = 0 then
    Exit(Value);
  Result := LongInt(LongWord(Value) shr Shift);
  if Value < 0 then
    Result := LongInt(LongWord(Result) or ($FFFFFFFF shl (32 - Shift)));
end;

I can see several ways to optimise the function but all of them make the code less readable. So I'm not going to do the optimisations unless I have to.

I should be quite trivial to create 8, 16 and 64 bit integer overloads of the routine.

06 January 2013

Shiny new XE3 and ditching old Delphis

Just installed my first Delphi update since the marvellous Delphi 2010. I sneaked in just in time to get Delphi XE3 pro from Grey Matter with a free copy of HTML5 Builder.

Not had chance to get to grips with XE3 or HTML5 Builder get, but have tasks in mind for both. XE3 is silky smooth on my relatively new ASUS development laptop, so I'm pleased with the pairing. Or perhaps its the fact that my previous development machine was a five year old Dell box that everything seems so fast at the moment!

No, what really got me tapping the keyboard is to say how much I appreciate getting license for Delphis back to 2007 + Delphi 7 as part of the XE3 licenses. Good on you Embarcadero!

I've never managed to acquire such a complete set before. I find them useful for testing my ddab-lib code library and for running tests on code in the Code Snippets Database.

So over the next weeks I'll be testing the code library with Delphi 2007, 2009, XE, XE2 and XE3 and making any necessary tweaks. And I'll be using my copy of CodeSnip to test the Code Snippets Database with the newer compilers and publishing the results.

As for HTML5 Builder, I'm hoping to use it for developing the new JavaScript based version of the online Code Snippets Database - Code Snippets Database – Take 2. Just hoping it's better than its PHP Builder predecessor!

One more thing while I'm talking about testing code with older Delphi compilers. Since moving to the new laptop I've decided not to install my ancient Delphi compilers (i.e. 2, 3, 4 and 6), so I'll no longer be testing code with them. My beloved Delphi 7 will be the earliest I'm going to go.

03 January 2013

CodeSnip project hosting changes now complete

I recently gave notice that my CodeSnip project was being migrated to the new "Allura" forge software by SourceForge, and then decided to move CodeSnip's Subversion source code repository to GoogleCode.

I'm pleased to announce that the migrations are now complete and have been tested. Here are the relevant links:

Some of the old Subversion URLs may keep working for a while, but the the old repository will not be updated.

CodeSnip's download files (source and executable) remain on SourceForge at:
https://sourceforge.net/projects/codesnip/files/.

The bug report and feature request trackers remain on SourceForge but have new addresses:

If you've been using the old CodeSnip SourceForge project, please update your links.