Text formatter functions in a clarion app

I am NEW to GitHub, I have just spent a lot time trying to figure out how mark this repository as Clarion code, no luck yet.

Regardless, years ago I took the code from Text Formatter chapter in Software Tools in Pascal by Kernighan & Plaugher and converted that to Clarion. I needed to implement a letter writer that could format paragraphs from a letter type file and then substitute variable names with data. I also needed to format text in specific size boxes that could be placed on a printed form.

The ReadMe.md file on GitHub shows how to run an example that displays in a message box.

Hopefully at some point I find the settings for specifying language on GitHub,

Include the generated CLW files (TxtFo*.Clw) which CLW extension is seen as Clarion which APP is not.

They are nice in the Repo so we can see what the code does without having to open the APP and generate. They are also helpful if someone does build the APP they can compare their generated CLW’s to yours to see if there are template differences. Also include other generated files like INC,EXP,…

Its also good to create a TXA of the APP and put that on GitHub. The TXA usually can be loaded into older versions where the APP would be rejected. If you have a DCT also export and include a DCTX.

Example of the School APP on GitHub with the TXA, CLW, INC files:

Thanks. I’ll do this

I still run C6 and I know others just use Clarion as handcoded projects.

So. . .AI directions for some GitHub stuff need human help. Found .gitattributes and also language is configured automatically, which is why adding .clw files works.

Found the book in PDF format.

Chapter 5 Text Patterns.

The wider website is interesting https://hardwarecomputerist.atariverse.com/

and found a very interesting book.

Thanks for the link. I don’t have the book, borrowed it in the 80’s and have photocopy of the text formatting chapter. Myself and long time friend did a lot of Pascal. Since you have the book you have the documentation for the Clarion code to format text. :slight_smile: Some years later Alan Holub (Dr. Dobb’s) had his version of nroff (NR written in C) for sale. I bought that and used it to create a reporting system where I could automatically float columns of data horizontally across, for a DNA/Blood typing laboratory. This code was way-to-overkill to use for Clarion solution.

My local bookshop https://www.waterstones.com/bookshops/cambridge-sidney-str massively scaled back on IT books in the early 00’s and alot of the content was not online back then.

IT in the UK was crap in the 80’s, 90’s, 00’s, got taught Pascal but school books were nothing like this Pascal one.

Even this one by the same authors looks good for beginners who want to get into programming.

I have this book. I spent 8 years using Python, until July 2023. Python would be easier I think for beginners.

Its more English like and less curly braces or abstract like you see in C/C++ or other languages.

There’s some truly wacky programming languages out there!

Code from your CLWs for the FormatText() procedure:

! ------ TxtForm.clw -----------
   MAP
     MODULE('txtform001.clw')
       FormatText(*STRING,LONG)

! ------ TxtForm001.clw -----------
FormatText           PROCEDURE (TextIn,TextInSize)  
  CODE

A tip is since at least Clarion 4 the Procedure Prototype and Parameters can be the same with both as (TYPE Label). The makes it easier you can type the Prototype then copy/paste into Parameters … except no Return type on the end.

I mostly like this because in the Embeditor at the top your Parameters shows Types so I know its a *STRING and LONG.

Your code adjusted:

! ------ TxtForm.clw -----------
   MAP
     MODULE('txtform001.clw')
       FormatText(*STRING TextIn, LONG TextInSize)

! ------ TxtForm001.clw -----------
FormatText           PROCEDURE (*STRING TextIn, LONG TextInSize)  
  CODE

Actual example, note Return of “BOOL,PROC” is not in Parameters. The Default =FALSE can be in Parameters, but the actual value used is from the Prototype.


One other tip is the Prototype and Parameters can have different Labels. In the Prototype I’ll put more verbose labels that are more like documentation, this shows in the Intellisense popup. In the Parameters I’ll put more terse variables that I want in code. E.g.

   MAP
       FormatText(*STRING InTextToFormat, LONG SizeOfInText)

FormatText    PROCEDURE(*STRING pTxt, LONG pLengthTxt)  

Thanks. last time I looked at that code was in 1999, I think.