Create and process 'dynamic' BBEdit Text Factories

Create and process 'dynamic' BBEdit Text Factories

I work with long lists, which sometimes I need to split into constituent parts. BBEdit Text Factories can do this well, but it can be a bind to create all the different versions needed.

Then it suddenly became clear to me that these could be written by KM. The text factories themselves can easily be accessed using a utility such as TextEdit and one can quickly see where the functionality is.

I have tried to demonstrate this with a simplistic example, imagining a list of fruits from which the constituents need to be extracted and written to individual text files.

The only really interesting part of course is the idea that a Text Factory can be created on the fly, and I'm sure you will be able to modify your own...

Keyboard Maestro Actions.kmactions (11 KB)

Hey @Rather,

BBEdit's Text Factories can be useful, but they are relatively slow and awkward compared to AppleScript.

A very simplistic example:

---------------------------------------------------------
set extractList to text 2 thru -2 of "
Apples
Oranges
Bananas
Grapes
Kiwi fruit
Cape Gooseberries
"
set extractList to paragraphs of extractList

tell application "BBEdit"
   activate
   set theDoc to ID of front text document
   tell text document id theDoc
      repeat with theItem in extractList
         process lines containing matching string theItem ¬
            matching with grep false ¬
            case sensitive false ¬
            output options {copying to new document:true}
         ""
      end repeat
   end tell
end tell
---------------------------------------------------------

-Chris

Hi @ccstone,

There is supposedly an Inuit word for that feeling of anticipation when you’re waiting for someone to show up at your house and you keep going outside to see if they’re there yet, which is Iktsuarpok.

I’m afraid that AppleScript is like Inuit for me. It may be more useful, descriptive or poetic but it’s not my language. I used to be able to knock out some lines of BASIC when I was a kid and later had a floppy of fairly unwieldy batch files for DOS and that’s really the extent of my knowledge of programming languages. Perhaps I am a frustrated programmer or scripter; I certainly enjoy using KM.

I see many examples of elegant solutions on these forums featuring AppleScript and have even copied a few for my own use, but while it’s interesting to know that iktsuarpok means that feeling of anticipation when you’re waiting for someone to show up at your house and you keep going outside to see if they’re there yet, I wonder whether I should really take the time to learn that language and write a few phrases of my own!

The written word can make it difficult to convey some meanings, so please be assured that I do appreciate your comment.

Rather.

Another old-timer! Right on!

IBM 370 and FORTRAN with punch-cards and a line-printer?

Been there; done that.  :sunglasses:

-Chris

Hey Rather,

Repetitive processes demand automation. If you have many of them that employ BBEdit I'd say it's worth your while to learn at least a little bit of AppleScript.

There's more than a few scripts to look at on BBEdit-Talk.

https://groups.google.com/forum/#!search/"Christopher$20Stone"$20"tell$20application"

I'm usually available for advice, and there two good AppleScript communities – the Applescript Users List and MacScripter.net

-Chris

1 Like

IBM 360/30, Burroughs 2800 (I think), all with punch cards and line printers. My wife, also.

Have you beat :-). My first machine was an IBM 1620 programmed in decimal machine language through a primitive punched card mechanism. Debugging consisted of halting the program (or more commonly it halting itself), then turning a large dial that chose which register you wanted the lights to display. That machine was my first computational love, and as such has a special place in my heart and brain.

God I'm old.

Heh. I learned on a DEC PDP8 using a teletype terminal with an acoustic-coupler modem. It had paper tape! We used to write programs to punch out text on the tape.

That was in high school. God I’m old.

I started my addiction in high school too – barely – I was 16. The 1620 came with three choices of memory: 20,000, 40,000, or 60,000 digits. I remember getting all excited when IBM came out with its fancy new card punch – forget what they were called – the blue and gray ones that didn’t look like teletypes. You could put a punched card on this spool in a little window that would control things like where the comment column was. It was very weird to me when much later on I found myself teaching students who never actually touched – and in some places never saw – the computer they were using. Anyway, I didn’t stay loyal to IBM for long — was a DEC man almost from their beginning. PDP-10 through many of its iterations. I loved its macro language.

So much for BBEdit text factories. :stuck_out_tongue:

1 Like

I was a user (and not a programmer) of a customized Perkin-Elmer computer: fed by Pertec tape-drives, driven by a teletype, output to a disk drive that would break your back when lifted, along with plotters the output speed of which I have never seen matched. We were astonished when two full racks could essentially be replaced by an IBM-clone 286.

1 Like