Category Archives: 4D

CUrly Mail Fun

Oh no…

Not ANOTHER E-Mail component.
Can’t someone create something fun for a change?
A Plugin to use excess client computing power to mine Bitcoin or something useful like that?

Well, sadly yes!
Yours truly is delivering to you yet another E-Mail component to add to your growing toolchest of more or less useless code.

And mine is bigger and much more powerful, also it’s by me, Alex, so it obviously immediately climbs to the top of your choices. Doesn’t it?

Oh get over it already, say what you want to say and be done with it!

Continue reading

I can grab your Listbox

Admitted, a cheesy title line if I ever saw one…

It’s been a bit quiet in here lately, could be because I exchanged my keyboard and desk for this during most of October:


That’s Indonesia, at the beginning of the rainy season.

But now to matters at hand:

Exporting Listbox content!

Continue reading

Holy IMAP folder Batman!

Ok, anyone around here ever had to deal with IMAP folder names?
Outside the US?
For non – US client?

You might have noticed, that the array of folder names returned by IMAP_ListMBs may contain funny stuff like

INBOX.Gel&APY-schte Elemente

or

INBOX.batman&ZeVnLIqe-.&U,BTFw-robin

never seen those?
never cared?
what’s IMAP?
use english words, dumdum!

otherwise: read on Continue reading

SOUNDEX shmockdex

Back in 1918, in the US, a patent was given to whatever passed as nerds back then, who invented an algorithm for finding similar sounding names and words, such as John and  Jon or Schmitt and Schmidt.
Back in the days and only working with the names common in the US at the time (thing was made for the census) the SOUNDEX algorithm has aged a bit and certainly not transported well to foreign languages.
In some countries, other nerds found new ways of doing it (Kölner Phonetic in Germany for example) but many of those were geared towards the specific target market.

Nowadays, with the percentage of people with migratory background rising everywhere, it has become more difficult to perform this task.
To the rescue : Phonet and it’s posh sibling Phonet2.

As a quick look into the 4D documentation will tell you, there is no such thing in 4D, so we need to roll our own.

Another quick google further and we find the algorithm definition and pseudo code for it…
Nah…
Too complicated!
Well, challenge accepted!

Continue reading

View Log Files, not only local ones!

I have some fairly complex stuff going on in my database and there are some operations that users can log into the logs folder, so if there are any problems I can try to figure out what went wrong.
Now most of my customers work on Client-Server, some on Citrix or even Terminal Server.
This means they have no easy way of accessing the required folder (for example:  /Users/AppData/4D/Roaming/Local/MyDatabase_10_123_221_17/logs), and even if they do, users nowadays are not what they used to be, they have no clue what to do…
So I needed another solution to retrieve and view log files from other clients.

This is where my wonderful new component AC_LogViewer comes to the rescue! Continue reading

A quick one : Epoch & Unix Timestamp Conversion

Found this useful for making date and time calculations, as you can add or subtract any number of seconds to or from a given date and time.

Base for this ist the Unix Timestamp or Epoch: basically just the seconds since midnight 1970-01-01.

Below you will find 2 methods to convert a date and time into Epoch (a longint) and to convert Epoch back into an ISO date-time string that can easily be used with the Date(string) and Time(string) 4D commands.

Continue reading

DebugLogFile Analysis for fun and profit

Has anyone here ever used the 4D Debug log that can be created by switching on

SET DATABASE PARAMETER(Debug log recording;x)

No? Yes? How useful was it?
Until recently i never even looked at it, too much data too little visible information.
That changed once I saw a nice little piece of code written by Justin Carr from Australia. Called DebugLogReader it does just what’s advertised on the box: It reads your log files and displays the data in a meaningful way.

As I was just tasked to optimize some code from a database I had not written (well not initially) I put it to the test and after some fiddling I was able to shave roughly 12 seconds off opening a product record. 12 Seconds is an eternity for users, especially when browsing through a selection!

That’s when I decided to extend this wonderful tool and with Justins kind permission I hereby present:

DebugLogReader 1.01

Continue reading

Translate Text with YANDEX

For the translation of a user interface I needed a quick way to translate smaller strings into several languages I do not speak.
So the obvious choice would be to call Google to the rescue.
Sadly. the Google Translate API is not free, so I looked for alternatives and found on, of all places, in Russia!
YANDEX, the Russian version of Google, offers comparable services, only they are for free.
As I do not have any ideological issues here, I wrote a quick component that can make use of the YANDEX API for translations.
Interested?

Continue reading

Quick editing of XLSX files

Ever felt the need to modify the content of Excel XLSX files?

Well thanks to Keisuke opening up the intricate content of a Microsoft OPC file (docx;xlsx;pptx;etc…) we can now easily edit the content of the Excel spreadsheets fiddling around with XML.

Or rather, it could be easy if Microsoft had devised their open document formats in a straightforward way, but being Microsoft and having written the decisive chapters of the industry standard cookbook obfuscating code for sociopaths  they have made it as complicated as possible.

Well I can at least help alleviate the pain a bit with a little component you can download here:

Download AC_XlsxEdit from Dropbox

You will need to download the OPC Plugin from Keisukes Github repository:

Keisukes OPC Plugin on Github

The component is V14 but should work with all versions of 4D.

Continue reading

SQL Structure Access

Sadly I lost a client last week as they decided it would be more expensive to pay for all the missed updates of 4D than to buy something completely new…
At least I got them to pay for me helping to export that data from 4D to something  the new supplier (who is using MSSQL server) could read…

Well I thought, that’s going to be quick money and fired up SQL EXPORT DATABASE

Boy was I wrong…

As long as you stay within the 4D Universe all may be fine, but no other SQL database engine can read these Export.sql files 4D creates, simply due to the way they write the INSERT INTO line…

INSERT INTO [ATY_TITLES] ( [ATT_ID] , [ATT_ATY_ID] , [ATT_TITLE] , [ATT_HANDLE] , [ATT_WTS_ID] , [ATT_WTP_ID] )

This may make sense for 4D, as there are apparently still some people out there who use spaces in field and table names (allowing spaces, special characters etc. in object names was not one of the better ideas Laurent ever had…) but all other SQL systems will just reject this syntax as being utterly ridiculous..

I also found out, that contrary to other SQL dumps, for example by MySQL, the 4D dump does not contain the CREATE TABLE statements needed to recreate a compatible structure.

A quick search revealed there is no such command in 4D, all these nice structure exports to XML, HTML, etc. are absolutely useless in this context (has anyone noticed that you cannot print the structure anymore?).

So, only solution, roll my own.

Continue reading