Sometimes it is a good idea to hit the dot

I wonder how many of us think that AL is C/AL but in nicer packaging? And because of that do not think that some, even small things, could be written differently and more easily.

That’s (I must confess) sometimes is also my case.

What happened when you hit dot after a text variable?

Lately, I found out that, there are things which I did not expect. For example, there are methods for the text variables.

I was used to using CopyStr(), DelStr() or for example LowerCase(), and never thought it can be done in a different way.

It turned out that there are methods which can help. Also, it seems they are there for quite a long time so maybe it is just me who missed them?

You cannot find the same in C/AL.

How to use them?

Very simple. Let’s check the easiest example – I want to print all in capital letters. I can do it in two ways. Either use the method UpperCase() or can use a method on the text variable instance.

But there are more useful things. For example, when you want to check if your string contains some substring in the past you needed to check if the position of substring is different than 0.

Now you can get it more elegantly. Simple use Contains() method on the text.

I will show you one more example. Let’s remove some characters from the end of the string. You can use the method TrimEnd() instead of DelChr().

Works not only on the variables

The methods work not only on variables. But also, on methods or procedures that return the text. For example on Format().


I only showed a few examples here. Must say that I was surprised when someone showed it to me. And I like it very much. If you are interested to find more what can be done you can info about this on Microsoft Docs

One Comment

Add a Comment

Your email address will not be published.