HOME - - - - - Lazarus Tutorials TOC - - - - - - Other material for programmers

A generally useful skeleton, boilerplate

As "grist" for "mill":
Encrypting/ decrypting the contents of memos
Loading/ saving memos to .txt files

file: lt3N-code19124.htm

This "tutorial" is mostly in the sourcecode that is supplied with it.

It was created 25 Jan 2019... and reflects many years of teaching programming, and of learning to present material on the web. And it is simple enough that it doesn't get into the tangles that, head hanging with shame, I have to admit exist in some of my free, oh by the way, offerings.

Fetch the .zip file, load it into your Lazarus IDE, and dig around in it, reading the rems.

I hope that you will find your way around relatively easily, and, while investigating the code, find useful tricks. More on what is there in a moment. First "the beef"...

I have posted a zip file with the sourcecode, and a compiled .exe... large swathes of that can be ignored, just used, if your main interest is playing with encrypting/ decrypting text.

Two ways to enjoy the code...

The code can be used on two levels... even three!

The "third" way is to use it, as it is supplied, to encrypt text. A compiled .exe file is included, to make this easy for you. (And to let you "play" a bit with the "finished" app, to see what it's features are before you delve into the code.)

The as-supplied encryption might give a ten year old 15 minutes pause... 2 minutes, if he/she had a eureka moment.

But! The first way to use the code is to ignore almost everything in it, and merely revise the sEncrypt and sDecrypt functions, which you will find at the bottom of the code. Back up the code as supplied before you tinker with it! Start slowly. Try something simple. (Walk before you run.)

The remaining way to use the code is as a boilerplate, or at least guide, for doing certain general things in your own work.

Boilerplate/ Guide

Inside the code, you will see an example of using an ini file to "remember" the dimensions and position of the app's window between uses.

Look at how the constants sPrgmName and sVers are used. I comment that practice to you in all Lazarus work, for keeping track of what you are doing, and what version each of your projects (and each copy of each!) is in.

You'll see how to load .txt files to TMemo objects, and to save the contents of memos to text files.

Look at how the "unnecessary" constants kPlain and kEncry helped make the code in LoadMemo(bWhich:byte); and SaveMemo(bWhich:byte); easier to follow. (And, oh by the way, note how what might have taken four procedures was reduced to only two procedures by making the procedure more generally useful.

There's code to learn from that shows you how to work through the contents of a memo character by character.

Code that turns characters into numbers, and numbers into characters.

Test on Tuesday!

I hope the code proves useful

Feedback... or just a "that was useful"... always welcome. Maybe this could be a starting point for an assignment to a class doing Lazarus programming? What ideas did students come up with?

Search across all my sites with the Google search...

Custom Search
            powered by FreeFind
  Site search Web search
Site Map    What's New    Search This search merely looks for the words you enter. It won't answer "Where can I download InpOut32?"
Ad from page's editor: Yes.. I do enjoy compiling these things for you. I hope they are helpful. However... this doesn't pay my bills!!! Sheepdog Software (tm) is supposed to help do that, so if you found this stuff useful, (and you run a Windows or MS-DOS PC) please visit my freeware and shareware page, download something, and circulate it for me? Links on your page to this page would also be appreciated!
Click here to visit editor's freeware, shareware page.

Link to Lazarus Tutorials main page
How to contact the editor of this page, Tom Boyd

Valid HTML 4.01 Transitional Page WILL BE tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org. Mostly passes. There were two "unknown attributes" in Google+ button code. Sigh.

If this page causes a script to run, why? Because of things like Google panels, and the code for the search button. Why do I mention scripts? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....