Lazarus – Simple Case of Features, Learning Progress

 


I really like the Delphi language. A long time ago, I programmed in Delphi 7.0. I still remember how one of the students next to me joked, "What the heck is this Delphic Oracle?" "What the heck is Delphi?" Today, within this framework, there's the Lazarus programming environment. Lazarus. A modern environment for programming like Delphi.

I'm also currently learning Lazarus. Good old Delphi. As they say. For a modern Windows system. And I want to share some simple points. I'm spending time learning myself. And I've decided to write about this as a blogger, too. Simple things. In line with the popularity of Delphi and Lazarus.

Anyone who programs in Turbo Pascal, Free Pascal, Delphi, or Lazarus knows the wonderful Case of operator. The selection operator. In other programming languages, it looks like Select case, Swith. It's like a variant of the conditional operator. They're studied right next to each other. Right at the start.


 

It's convenient to iterate over values ​​using Case of. This has saved me more than once. In the Lazarus environment, you can create variations on this operator.

You can specify multiple enumerations, writing multiple values ​​directly in a line. You can demonstrate this using the alphabet as an example. Specify a bunch of possible values ​​in one line.


C:='f';

case С of

'a','b','c','d','e','f','g','h':

Memo1.Append('[a-h]!');

'i','j','k','l','m','n','o','p':

Memo1.Append('[i-p]!');

else

Memo1.Append('out of range [a-p]!');

end;


Or you can write ranges. For example, when we encounter a case in the range from 1 to 10. Perform such-and-such action.


A:=15;

case A of

1..10: Memo1.Append('[1-10]!');

11..20: Memo1.Append('[11-20]!');

21..30: Memo1.Append('[21-30]!');

else

Memo1.Append('Out of range [1-30]!');

end;




When I first started learning, I was confused by the Else branch of actions. This branch is different. There's no colon there. So that you can start describing the case later. Just the else keyword. And the case starts right away. And you don't have to put begin and end there. You can even do without them. Even if there are a bunch of operators. This really surprised me. For me, the entire Pascal-Delphi language family is closely associated with the begin-end construct. Don't know what to write? Write begin-end. As they say. It'll look smart. You write some operators. Something there called begin. Somewhere there called end.

 

A:=15;

case A of

1..10: Memo1.Append('[1-10]!');

11..20: Memo1.Append('[11-20]!');

21..30: Memo1.Append('[21-30]!');

else

Memo1.Append('Out of range [1-30]!');

Memo1.Append('your A is' + IntToStr(A));

end;


So I'm learning! And I'm sharing my impressions of learning. About simple things!


Dima Link is making retro videogames, apps, a little of music, write stories, and some retro more.


WEBSITE: http://www.dimalink.tv-games.ru/home_eng.html 

ITCHIO: https://dimalink.itch.io/


TUMBLR: https://dimalink.tumblr.com/

BLOGGER: https://dimalinkeng.blogspot.com/

MASTODON: https://mastodon.social/@DimaLink

Comments

Popular posts from this blog

Moon - gray stone, which attracts

Atlas H376 – Killing Floor, creep and trash floor, that kills