Paramuments: Making Functions more Functional

Introduction

We’re going to revisit the coin slot and see how we can use it to let functions take variable inputs to produce more dynamic outputs.

Scope of Application

Today’s post was drafted using Microsoft Word 2013 running on a Windows 8.1 machine. But what I’ll cover applies at least as far back as Word 2007 and Windows XP and the equivalent versions of Word for the Mac. If you don’t have Word, you can get a trial copy from Microsoft’s website.

A Quick Review of our singleDouble macro

In my Cheater’s Code trilogy, I showed you a macro that turned out something like this (edited for focus):

Sub singleDouble()
'
' singleDouble Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ".*<"
.Replacement.Text = ".  "
.MatchWildCards = True
.MatchCase = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

 

We used that to replace a period followed by anything leading up to the beginning of a word (“.*<“), and replace it with a period followed by two spaces (“.  “)–or, in other words, to find a period followed by any number of spaces, and replace it with a period followed by two spaces.

Then I pointed out that we’d have to correct for things like Dr., Mrs., etc. showing up elsewhere in the text by running a very similar macro:


Sub correctSingleDouble()
'
' correctSingleDouble Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "([DIJMNOPRS][cdnoprst]{1,3})(.  )(<?)"
.Replacement.Text = "\1. \3"
.MatchWildcards = True
.MatchCase = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

 Well, you probably noticed that with the exception of the Text and Replacement Text, the code of these two macros is exactly the same. Now imagine that you have 10 different find and replace searches to perform on each document you work on. Repeating this one pattern 10 times would produce over 100 lines of code–but the only thing changing are the find and replace values. Sure, it’s easy to copy and paste all that, but it’s not really efficient. For that reason alone, we should look for a way to change the values without repeating the rest of the code. We’re looking for reusability.

Parameters

This brings me back to the coin slot. In case you don’t remember (or skipped my Cheater’s Code trilogy), I referred to those parentheses after the macro name as a coin slot and compared it to those machines at the mall that smoosh a penny. The machine has a place for you to pass something in, and when you do that, it sets to work on what you’ve given it. The machine doesn’t care what year the quarters were minted in, whether the penny is a wheat penny, or if you also have six nickels in your pocket. The machine will not, however, accept forms of currency it doesn’t expect. You can’t put an equivalent amount of Yen into the machine and make it work. It knows the size and the shape of the input it wants. And that’s what we would call a parameter in programming parlance.

Parameters basically allow you to do two things:

  • Enable a function to accept input
  • Describe the type of input the function will accept

In our macro, we want to pass in a Find value, and a Replace value. That means we’ll need two parameters. We create them by giving them names and identifying their types in the parentheses after the macro name–carving out the coin slot. Let’s create a new macro called “findReplace” and set up some parameters:

Sub findReplace(findThis As String, replaceWithThis As String)

End Sub

Different programming languages can handle this slightly differently, but in VBA you provide a name (something you make up), followed by As [Type]. If you don’t quite understand what I mean by “type,” I’ll be covering that in another post. Don’t worry about it too much now. You know that this particular macro is working with strings, so we need our parameters to be strings.

Let’s go ahead and fill in the rest of the macro:

Sub findReplace(findThis As String, replaceWithThis As String)

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = findThis
.Replacement.Text = replaceWithThis
.MatchWildcards = True
.MatchCase = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

End Sub

Notice that now the Text and Replacement Text now point to the names of our parameters. Going back to our penny smoosher comparison, this is like saying, “Take a quarter and a penny. If it’s a nickel or a dime, don’t accept it. Also, it doesn’t have to be any particular quarter or particular penny. It just needs to be a quarter and a penny.”

Now you can call this macro and pass in any two strings.

Arguments

When I was starting out, I found the difference between parameters and arguments to be a little confusing. Basically, it’s this: when you carve out a coin slot, you create parameters. The slot for the penny and the quarter are the parameters. The quarter and the penny–the objects actually going into the coin slots, are the arguments. Parameters define the input allowed, arguments are the input. (If anyone knows why we use the term arguments, I’d love to be able to answer that trivia question.)

Now that we have findReplace, we don’t need all that code in singleDouble. In fact, we really only need one line of code there:

Sub singleDouble

Call findReplace(".*<",".  ")

End Sub

 Simple, right? findReplace has a place for two strings, and we’re giving it two strings. It will use them as the Find and Replace values, respectively. We passed in the values we want to use as arguments. Hopefully now you see where the title of the post comes from.

We could make the same edit to correctSingleDouble, but in this case I’m pretty sure that whenever we replace one space after a period with two spaces after a period, we’ll want to correct for abbreviations. Since both operations always need to be performed, we can just stick them in the same macro. Remember, that would have originally meant 20 lines of code. Now that we have the findReplace abstraction, it’s just two lines:

Sub singleDouble

Call findReplace(".*<",".  ")
Call findReplace("([DIJMNOPRS][cdnoprst]{1,3})(.  )(<?)","\1.  \3")

End Sub

Now when we find ourselves in a situation where we need to run the same function on 10 different sets of strings, we don’t have to copy and paste 10 lines of code over and over. We just generate one new line of code for each new find and replace operation. That will make it easier to read, easier to edit, and boost performance.

Prompt

If we had 10 find and replace options to perform, how could we make this even more efficient?

Love and kisses,

Tyler

Discounted iOS Development Boot Camp

Somebody passed along this link, and so I thought I’d pass it along to you in case you were interested: http://stacksocial.kinja.com/udem-1517879920.

This is a generously discounted boot camp course for total beginners. You don’t need to know how to code at all to start, but you will need access to a Mac running OS X Snow Leopard or higher. If you’re thinking, “If I have to buy a Mac to do this, the discount doesn’t help much,” well, I agree. But if you can get your hands on an OSX86 ISO, you can run this in a Virtual Box. I haven’t experimented with that and so can’t provide any specific links or suggestions, but that’s how I’m told it’s done.

So for those who might be interested in developing for the  Mac ecosystem, this is a really good way to get in on the ground floor with some concrete direction.

Tools of the Trade

Introduction

This post points to a few outstanding tools for developers. It’s a short list of things that I’ve found really helpful as I’ve tried to teach myself to code. Obviously any resource is helpful, but right now these are some of the most popular and widely-used resources. You’ll get more deeply embedded into the culture more quickly by getting familiar with these tools early. As I’m a .NET developer above all else at the moment, these tools skew that direction.

Scope of Application

This applies to anyone looking to learn to code who has access to online resources. As of April 2014, most of this was pretty hot stuff and on the list of what the cool kids are using.

Stackexchange

As far as I know, this is the #1 place for Q&A information for programmers online. Stackexchange is an umbrella Q&A site that includes a long list of sites divided into general categories. It’s the coolest forum-like technology that I’ve seen. Specifically, you want an account on Stackoverflow.com. But Stackexchange users are protective of the site’s format and rules. Stackoverflow isn’t the right place for all questions. You might also want to link an account to Superuser.com, for example.

Generally, the community there is incredibly helpful. It’s mostly other developers hanging out, both asking and answering questions. Like any other online forum, it has its abrasive users, so if you “break a rule,” you might get bullied around just a tad. However, as long as you ask articulate questions and show yourself making an effort, you’ll be fine. And once you get a few tricks under your belt, you’ll also be able to answer other people’s questions. It feels good both because you’re giving back and because then you know you’re smarter than you were when you were asking the same question.

GitHub

To really understand GitHub, you have to learn a little bit about version control and open source. This article by James Bruce provides a pretty good overview. But to give you the elevator pitch – GitHub is a place and a way to store and share your code. Just as importantly, it’s a place to browse through tons of open source code.

(If you don’t know what open source is, I would describe it as code that anyone is allowed to download and read. Programs and services that run on open source code are not necessarily free, though the majority are. The opposite of open source is proprietary code, which is code that is only distributed in encrypted or compiled formats and isn’t intended to be read by humans. A good example is Microsoft Windows. The code used to build the Windows OS is proprietary and not freely distributed. However, many flavors of the Linux operating system are open source and can be reviewed by anyone who is interested in taking a look.)

Even if you don’t have any code to share yet or don’t feel quite ready to contribute to an open source project, this is a great place to dig into cool programs and libraries and start learning how they work.

GitHub does offer private hosting for a fee, but with a free account, you can host unlimited open source projects.

Gist

GitHub hosts a Pastebin service called Gist, as well. There’s not a huge difference between the overall concept of GitHub and Gist, but Gist has a more narrow scope. You use it to post single text files rather than entire projects or groups of files.

Visual Studio Express

I haven’t included a lot of actual downloads here, but I think this one is important. I started learning to code on a Windows machine and was tasked early on with developing solutions in a Windows environment. Visual Studio isn’t the only way to do that, but it’s the most powerful and the most convenient. When I first looked at the sticker price on Visual Studio, though, (and before I realized that most companies will purchase it for you if they expect you to use it (What can I say? I’m a dummy)), I was pretty intimidated. It’s an expensive tool. But Visual Studio Express is a free version that offers more than enough functionality for beginners. There are similar tools out there for programming to other environments, but I just wanted to point out for the total noobs that you can get your hands on Visual Studio and start using it now for $0.

Nuget

Nuget is a plug-in for Visual Studio that gives you quick and easy access to tons of cool code. If you decide to program for Windows, you will hear about Nuget, and you will quickly come to love it. Basically, Nuget makes it really easy to host and consume code libraries. If you don’t know what those are yet, get Nuget anyway. As soon as you find out what code libraries are, you’re going to want it.

Chocolatey

Chocolatey is Nuget’s Windows programs counterpart. What Nuget does for code libraries, Chocolatey does for programs. Quick snapshot: You know how when you want to download a program like Skype you have to go to the website, download the file, find the file, then run the installer? Well, Chocolatey makes it so you can just type the line “cinst skype” into the command line to do all of that automatically. In a lot of cases, you don’t even have to interact with the installer. It does everything for you.

Chocolatey doesn’t host every single program for Windows, but it hosts an impressive number. I’ve only found a handful of programs that I use that I can’t get through Chocolatey.

Boxstarter

Boxstarter is something I’m still figuring out, but I’m absolutely sure it’s awesome. Basically, Boxstarter works with Chocolatey to make setting up a Windows system a one-command process. Quick snapshot: You just got a new computer. Now you have to go find all your programs, download them, install, etc., etc. Boxstarter allows you to write a pretty simple PowerShell script (which you can host on Gist, by the way–see how things are coming together?), which will then do all of those things for you.

I haven’t traditionally been a PowerShell user, and I just got started on Cocolatey a few months ago, so I’m still trying to get a handle on Boxstarter. But again, I’m absolutely sure it’s awesome, and it’s going to change the way I spin up a new computer.

Pluralsight

This is the first thing on the list that has no free version–but it is worth ever penny. Pluralsight is web site that hosts training videos on a huge range of topics–everything from coding to professional development. It is heavier on the .NET technologies than open source, so you’ll probably get the most value out of it if you’re going to program for Windows. The training is well-composed, and they have a couple different subscriptions. One just gives you access to watch the videos. The next tier gives you access both online and on a mobile device, includes pre- and post-assessments of the various courses, and provides exercises. They also do an excellent job of labeling the material appropriately for your skill level. Beginner? Well, then don’t take the “Advanced” course to start out.

Coursera

You’ve probably already heard of this one, but I recommend getting an account. This is an awesome online learning center that is adding topics all the time. Unlike Pluralsight, which I would say is more like vocational training, Coursera is structured as an online academic institution, offering courses on everything from robotics to anti-terrorism to business management from schools such as Princeton, Stanford, and the University of Copenhagen. They just added a feature they call “Specializations,” which allows you to earn a series of certificates that demonstrate a proficiency on a certain topic. For example, they have specializations on Data Science, Challenges in Global Affairs, and Mobile Cloud Computing with Android, among several others. Whether or not future employers or academic institutions will recognize these credentials is debatable and beside the point. The courses here are challenging and offer you opportunities to grow your knowledge and skillset with a more academic mindset.

Khan Academy

I’ve found Khan Academy to be a little hit-or-miss, but it’s a force to be reckoned with. The range of topics is huge. It has some programming and computer science modules, but I’m actually recommending it for the math. As I’ve mentioned, computers were designed to do math. I didn’t come from that background. As a matter of fact, for better or worse, I spent a lot of my time in school figuring out ways to get out of doing math. Majoring in English helped a lot. Not a lot of my programming requires much more than basic math skills, and I handle that just fine. But every now and then a topic comes up that requires me to know just a little bit more than I really do. The nice thing about Khan Academy is that I can usually go straight to the module that I need and figure out where that sits in the spectrum. For example, I didn’t have a great grasp of logarithms, so I went to Khan Academy, found a great tutorial on it, and was able to see from there that this was an Algebra II topic. (Sometimes I don’t know when a problem is algebra, trig, or calculus. I don’t get the differences.) So Khan Academy is a big help in showing me knowledge dependencies.

Miscellaneous

These are a few others that I either know by reputation only or have used only lightly.

  • Udacity – like Coursera but more like Udacity
  • Plunker – like Github but can actually run code live for demos and such
  • JSFiddle – cool web dev tool let’s you test HTML, JavaScript, and CSS. The advantage is that you can manipulate all three files and see the output on a single page.
  • JSLint and JSHint – JavaScript parsers that will let you know how good a shape your JS code is in
  • Regexpal – Simple tester for regular expressions that will give you immediate feedback by highlighting matches in sample text. Especially useful for learning regular expressions.
  • Safari Books Online – Unrelated to the Safari browser, Safari Books is a subscription service that gives you access to a library of books on tech. The library is exhaustive and often includes books that have yet to go to press. They’re also starting to add videos, which might make it more valuable than Pluralsight in the long run.

 

 

The Cheater’s Code, Pt. III: Wildcards

Introduction

Time to finish off this Find and Replace macro by introducing wildcards. This post is the last in a three-part series. If you want to know how we got here, check out Part I and Part II.

Scope of Application

Today’s post relies on Microsoft Word 2013 running on a Windows 8.1 machine. But what I’ll cover applies at least as far back as Word 2007 and Windows XP and the equivalent versions of Word for the Mac. If you don’t have Word, you can get a trial copy from Microsoft’s website.

Where We Left Off

I’ve had a bit of a lull here. Things at work got pretty busy, and I spent several nights working on a library to help analyze lists of files against collections of files to see if they match up. It’s called VennDexer, and the source code is up on GitHub if you’re interested. (If you don’t know what GitHub is and don’t understand what Google is trying to tell you about it, I’ll help you out in an upcoming post where I talk about tools of the trade you’ll want to know.) I also built a lot more macros, so I’ve got a lot of material to post in the near future. I won’t be analyzing them in depth like I have our Find and Replace macro, but I think some of them are good use cases for programming basic repeatable tasks.

But to get back to where we left off, a quick recap:

  • In Part I, we recorded a macro that found a period followed by a space and replaced it with a period followed by two spaces. We also covered what a macro is, in general terms, and why they’re useful. However, our macro had a slight problem. Even when a period was already followed by two spaces, it added a space.
  • The recording process in Part I automatically generated some code for us, so in Part II we examine that code in detail to gain an understanding of how it worked.
  • At the end of Part II, we looked at the source of the problem in our original macro–our logic. The computer was doing exactly what we told it to: finding a period followed by a space and replacing it with a period followed by two spaces. The computer takes our instructions very literally. We didn’t tell it to look for a period followed by one space and only one space. So whether the period is followed by 1, 3, or 100 spaces, our macro is going to find the match and do its job.

Knowing that the computer is going to take you literally to a fault is an important understanding in programming. Sometimes the programming language will help make up for this a little bit, but generally speaking the computer does exactly what you tell it to do–not exactly what you expect it to do. It’s like the old communication exercise where you try to explain to someone how to make a sandwich. Every time you say something, it’s wrong.

You: Get the bread.

Student: Where is it?

You: In the cupboard.

Student: What’s a cupboard?

Really, dumb dumb?

But it gets worse. You have to explain to the student to go to the cupboard, open it, grab the bag with the bread (and you have to explain which bag that is), and so on and so forth. It’s a really useful technique for teaching us how much we take for granted in our communication, and that’s really good to remember when you’re programming. If the computer isn’t doing something you want it to do, you should double check that you told it to do that thing. If it’s doing something you don’t want it to do, make sure that you didn’t tell it to do that. It won’t always be your fault, but I’d say at least 85% of my programming problems are a result of miscommunication problems. The computer is always doing what I say instead of what I mean. (The other 15% of my programming problems stem from the computer being incapable of making a sandwich.)

So we need a way to go tell the computer to look for a period followed by a single space and only a single space. Another way to put it is that we need the computer to look for a period followed by a space, followed by any character that is not a space.

I’m not going to run you through the logic of all the bad options. Obviously it doesn’t make sense to tell the computer to search for “. A”, “. B”, “. C” one after the other until we’ve accounted for every possible set. Not only is that terribly inefficient, but it would be be almost impossible to account for every single character. Also, and this is another key to programming logic, we can safely assume that we are not the first people in the history of coding who have had this problem. Just like we didn’t have to make up a computer language to enjoy automated find and replace functionality, we don’t have to make up the solution to matching large, vague sets of characters. A tool exists.

Wildcards: Not Just for Poker Anymore

You’ve probably already used wildcards, whether you knew them by that name or not. If you’ve ever gone into a file folder to look for all your JPEG images, you might have typed *.jpg in the search bar. The asterisk, or star, tells Windows that you don’t care what comes before the dot. You want to match anything file whose name ends in .jpg. So if you had the following files in a directory

hippopotamus.jpg

todoatthezoo.docx

penguins.jpg

passwords.txt

tigers.jpg

directions.docx

zoobudget.xlsx

and then you searched for *.jpg, you’d get back the following list:

hippopotamus.jpg

penguins.jpg

tigers.jpg

The star (*) is a wildcard. In short, that just means it stands in for something else. Specifically, in this context, the star stands in for anything else. I won’t be covering all the wildcards or how they could be used, but here’s an article that expands on the topic. Also, I found a really well-done blog post on how to do advanced Find and Replace in Word, which includes some info on using wildcards. For something a little more advanced, read this.

You’ll often see wildcards mentioned in the same breath as regular expressions. Just to be clear, Word’s wildcards do not function the same way as the wildcards in regular expressions. There is some overlap, but it is minimal. As you get deeper into programming, you’ll likely come across some regular expressions.  They may look a lot like some of Word’s wildcards, but don’t get the two confused. It is best to think of them as estranged cousins who don’t play well together–who maybe even give each other the evil eye on occasion. Don’t invite them to the same barbecue.

There’s More Than One Wildcard

Just to get another pet peeve off of my chest, the star or asterisk is not the only wildcard. A lot of folks get the impression that it is. The question mark, at sign (@), and angled brackets (<>) can also be wildcards, in addition to other characters. This is more of a snotty nerd issue, but armed with this knowledge, when someone tells you to “use the wildcard,” you have enough snotty nerd clout to say, “Which one?”

But I’ve Searched for the * Before and Found It

Remember that Word’s Find and Replace has additional settings. If you hit Ctrl+F in Word and search for the asterisk, it will match only the asterisk–not any character. But when you hit the “More>>” button, you’ll see an option to use wildcards.

advanced-fr-usewildcards

When that option is turned on, searching for the asterisk will match everything.

How Wildcards Solve Our Problem

My gut instinct might be to immediately add the star to the string we’re trying to find.

.Text = ". *"

Of course, it will only take you a second to recognize the flaw in my dummy logic. The star matches anything. That means it will match another space. So as soon as Word finds a period followed by a space, followed by anything–including another space–it will consider it a match and substitute our replacement text.

But the problem is a little bigger than that. This would also match “. A” or “. t”, or any combination of period, space, letter. When it replaces that text, it will also replace the letter we found.

Poo.

To solve this problem, we need to learn one more wildcard feature. I think it might be a little easier to see the solution and work backward from there. The solution will look like this:

.Text = ".*<"

.Replacement.Text = ".  "

The angled brackets are wildcards that represent the beginning (<) or end (>) of a word, respectively. So what we’re saying here is “Hey, Word! Find a period, followed by anything leading up to the beginning of a word. Replace it with period, space, space.”

Why Does It Work?

The wildcard expression works because it stops matching when it gets to the beginning of a word, which Microsoft Word considers to be any character. It doesn’t match on the character. Just everything leading up to it. This actually means that the expression is pulling double-duty. Not only will it find the combination period-space-character, but it will find period-space-space-space-character. In fact, it will find any number of spaces between a period and the beginning of the next word. So it will ensure that periods with too many spaces are also replaced by a period followed by two spaces.

Actually, It Doesn’t Work… Yet

If you try to run the macro now, you probably won’t get any matches. You definitely won’t if you’re using the source text I was in Part I. You know why, though. We have to turn wildcard matching on:

.MatchWildcards = True

Now it works. If it doesn’t work, have a couple Oreos to calm yourself down and go back through the posts.

We’ve Still Got One Problem

Let’s say this sentence is in the third paragraph of our document:

Dr. Smith called Ms. Johnson and asked her to come in for an appointment the following Monday a.m.

Dr. Smith and Ms. Johnson are going to give us a problem. We’re going to end up with some added space between “Dr.” and “Smith,” as well as between “Ms.” and “Johnson.” Other abbreviations show up in the middle of sentences all the time, too: Inc., Rd., St., Mr., Jr., etc. Again, the computer is going to take us absolutely literally. If we want it to do something different with abbreviations than it does with the end of sentences, we have to give it specific instructions. But I think I’ve given you enough ammunition at this point to leave you with two hints. The first is this: in all but a few rare cases, there are more sentences than there are abbreviations. Fix the spaces after a sentence first. The second hint is the solution:

.Text = "([DIJMNOPRS][cdnoprst]{1,3})(.  )(<?)"
.Replacement.Text = "\1. \3"
.MatchWildcards = True
.MatchCase = True

That wildcard expression isn’t perfect. I was still learning how to use wildcards efficiently when I put that together. But it works. I’ll leave it to you to figure out why it works. If you really get stuck and have no idea what’s going on, feel free to leave a comment or two. I’ll be happy to point you in the right direction.

Love and kisses,

Tyler

Make a Mobile Game without Programming — Yes… For Real

Last week I saw a great presentation on a tool called Construct 2 that let’s you make mobile apps (mostly games) without any programming know-how. Will programming know-how help? Absolutely. Can you make a pretty outstanding game without any programming know-how? Yes! It’s actually kind of amazing. In under two hours, I watched this guy build a mobile game from scratch without writing a single line of code. Granted, he’d prepared a practiced presentation and already had all the tools downloaded and ready to go. But you could build a game from scratch in a week easy if you knew what you wanted to do.

I’ve been kicking around an idea for a mobile game for a couple of years now, but I haven’t ever had the patience to get into building it. Mobile is a different environment. Games are a different kind of work than the business application programming I usually do. It takes some getting used to. I’ve tried starting a couple of times, but I always run out of time or patience before I get into anything interesting. Construct 2 made it a piece of cake. I came home from the tutorial and within a couple hours I had a working prototype of the game I want to build… without writing a single line of code!

Now, of course, I like to code. I’d really like to understand the code that Construct 2 built for me. But I’m not a game programmer by trade. I don’t have 10 more game ideas ready to go. I only have the one idea, and that’s part of the trouble. It’s hard to motivate myself to learn how to program games to build one idea. I’ve got other stuff going on, after all. Justified isn’t going to just watch itself every week. Now I can build my game without the slow drudge of learning a whole new skill set. I just tell Construct 2 what platform I want to build for, and it gives me drag and drop tools. Call it lazy if you want, but when my game hits the app stores, you’ll be glad there’s a lazy entrance to game programming! (No. I can’t reveal the game idea yet. Now that you know about Construct 2, you could beat me to the punch.)

Construct 2 has really good documentation, tutorials, and an active user-base. Plus, it’s free. Well, the free version is free. There’s a paid version with some extra features. I’d start with the free one and see if you need the extra features first, though.

If you want to program games and you want to build something you can put in the Windows Store or Play market today without learning how to call the APIs in a physics engine, give Construct 2 a try. (Especially if the phrase “call the APIs in a physics engine” sounds like total gobbledygook to you.) And let me know when your game is ready to download. I want to see if you put my name in the credits!

The Cheater’s Code, Pt. II: “Sorry I Asked” Edition

Introduction

I’ll warn you now that this is a long one. I’m trying to stick to my guns on making as few assumptions as possible about what you already know. I’m explaining things in a way that I wish someone had explained them to me when I was learning, and in a way that I hope can get me back up to speed quickly if I ever get code amnesia. So settle in. This is the “Sorry I Asked” Edition, and you’re the “I” in there.

This post picks up where the last one left off. If you didn’t do Part I, you may want to go back so you’ll have the proper context for what I’m talking about here. But the short version is that we recorded a macro, which automatically generated some code for us, and here I explain exactly what each line of that code means. I introduceseveral terms, including subroutine, function, and property. I also make a pretty good joke about the Great Illustrated Classics book series and make a compelling argument that Inspector Gadget is an excellent model for understanding some code structures. You don’t want to miss that.

Scope of Application

The screenshots and code for this post came from Microsoft Word 2013 running on a Windows 8.1 machine. But what I’ll cover applies at least as far back as Word 2007 and Windows XP and the equivalent versions of Word for the Mac. If you don’t have Word, you can get a trial copy from Microsoft’s website.

If I Put “The Secret of Macros” in the Header, it Will Seem More Mysterious

Last time, we recorded the following macro:

Sub singleDouble()
'
' singleDouble Macro
'
'
    ShowVisualBasicEditor = True
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ". "
        .Replacement.Text = ".  "
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub

I promised to go over it in excruciating detail, and when it doesn’t require much of me, I keep my promises.

First, I’ll point out that I’ve gained some experience since the first time I saw this. I’m going to do my best to remember what it was like to look at it with fresh, ignorant eyes. But feel free to leave me a question in the comments if I fail to cover something you’re interested in. I’ll also mention that even though I’d written some programs by the time I recorded my first macro, I still didn’t really get it. When I originally looked at this code, I literally googled it line by line–even the stuff that seemed self-explanatory. It’s a fragmented way to go about learning a section of code, but it teaches you how to dig for things. It will also introduce you to new code as you go.

So let’s assume that despite all the wonderful things I had to say about HWPs in my last post, you didn’t run out and find one to practice on. You decided to wait patiently for me to come back and show you what’s what in this macro. You agree with everything I’ve said about Oreos so far, and you’ve decided to trust me on programming, too. (In other words, you have questionable judgment.) Well, good. Because I’m going to treat this macro like it makes absolutely no sense to you at all.

The Language

If no one has told you yet, there are more ways than one to skin a lobster. (I’m pretty sure that’s how that saying goes. Or is it skim a lobster bisque?) There are also more ways than one to program a computer. There are dozens, if not hundreds, of computer languages. The one we’re looking at here is called Visual Basic for Applications, or VBA, and it was developed by Microsoft. It’s one of a set of languages with Visual Basic in the title. This can be confusing. When you get to googling, you’ll find posts about Visual Basic.NET or Visual Basic Script and try to apply what you learn in your VBA macro only to find it doesn’t work. And for a while you’ll blame yourself, being the noob that you are. I’ll go ahead and tell you now that sometimes it’s not you. It’s the language. So as you tinker with macros and try to educate yourself on the topic, make sure you’re looking at the right information.

You might be wondering why there are so many computer languages, and it’s a worthwhile question. The short answer comes down to two things: money and preferences. We’ll save the full discussion for another time. For now, just know that some of the abstract principles we cover will apply practically everywhere, but the diction and syntax you see here may not mesh well with another language you might be interested in learning.

I’ve chosen to start with VBA because it’s where I started, and because it’s a pretty friendly entry-level language. The big downside is that you have to have a copy of a Microsoft application to really put it to any practical use. So it’s not a totally free way to get familiar with coding, and there are free options. We’ll get to a couple of them later. For now, if you’ve come this far, I’ll assume you’re willing to indulge me recording my own coding history while trying to pass on a few pointers.

The Top and the Bottom

We’re going to start at the top, but since programs are like sandwiches, we’re also going to start at the bottom.

Sub singleDouble()

End Sub

Sub is short for subroutine. In the context of the Visual Basic family of languages, a subroutine is just a set of instructions that doesn’t return a value. I’m going to call a quick sidebar here and explain what that means.

Sidebar

I want you to think about three things you might find in a mall: an electronic door that you open by pushing a button, a parking meter, and one of those machines that smooshes a penny. The door doesn’t need anything from you except to push the button. It already knows everything it’s going to do. You just waltz up to it (unless you gallop, saunter, or hobble), push the button, and it does its thing. You see results and get something out of it, but you don’t provide the door with any special information about how fast you’re walking, how tall you are, or whether your expecting it to swing in or out. And the door wouldn’t care if you did. The door also doesn’t give you anything back. It does what it’s going to do regardless of whether you walk through it or not. This is just like one kind of subroutine in VBA. It’s just like our subroutine, actually. We push the button, and it runs. Yeah, when we recorded it, we had to tell it what the Find and Replace values were, but that was just because the code didn’t exist yet. Now it doesn’t need anything from us. It just needs us to call it by pushing the button. The parking meter takes some input: a certain number of coins. Once it has its input, it just does its thing and counts down. You don’t really get anything out of it. You get to not get a ticket, but it’s not like you own the parking space now or you get a special prize if you happen to put in a secret combination of coins. You just determined how long the clock will run by the input you gave it. In VBA, this would also be a subroutine, but one that takes arguments. The machine that smooshes the penny needs some input, usually at least a quarter and a penny, and it gives you something back. The smooshed penny is the return value. In VBA, a program that has a return value is a function. (Ok, you caught me. Technically, the parking meter has a return value: the time display. Shut up. It’s really hard to think of things at the mall that take your money, perform a function, and give nothing back…)

Nope. I said it had to perform a function.

Dummary: No return value, it’s a subroutine; yes return value, it’s a function. Subroutines and functions can both take input as arguments. Don’t get too bogged down in the terminology. I’d been programming on the job for a year before I took my first tech screen, mostly VBA code, and I couldn’t tell the screener what the difference was between a subroutine and a function. If you get it now, you’ll be a step ahead. If you want to stick with “program,” “code,” or “macro,” I won’t scoff at you. Only snotty nerds will, but there aren’t as many of them as you’d think. I’m going to use the official terminology, but replace “subroutine” with “macro” if it’s easier for you. The difference won’t matter today.

If you’re not at the sidebar, are you at the frontbar, the topbar, or the middlebar? Maybe the wunderbar! Anyway, sidebar is over, so we’re at the other bar.

So now we know we’re looking at a subroutine, and that’s why it has the Sub label.

Sub singleDouble()

End Sub

That makes it easy to guess what End Sub means, I hope. That’s where our subroutine ends. We need to point out where it ends for a couple of reasons. First, the computer isn’t as smart as you are. If you get a letter and someone forgets to sign it, you know that a half page of white space means there’s no more letter left. The computer just doesn’t get white space. It’s like an awkward silence that the computer has to get past as quickly as possible. If you don’t tell it where to end the subroutine, it’ll keep looking until it gets to a boundary like the end of the file. In other words, when the computer gets a letter from you that’s not signed, it just keeps reading. Trust me. It’s going to cause a breakdown. Make sure to remember to tell the computer where the code ends.

The other piece is the name of the subroutine, which we gave it when we turned on the recorder: singleDouble. But why are those parentheses there? I’m glad you asked. That’s the coin slot!

Think about the parking meter and the penny-smoosher in the mall. There’s a designated place where you can put the money. You can’t just lay the penny on top or hold it up where the machine can see it…the machine can’t see. And if you try to put a Canadian quarter in there, it won’t let you get away with that. The machine only accepts certain, pre-designated forms of currency. Programs that take input work the same way.

Our subroutine will eventually evolve to use the coin slot, but for now it’s going to stay empty. The important thing to know is that all of your subroutines and functions, whether they take input or not, have to have a coin slot. So as you start to look at different programming languages, you’ll get used to seeing parentheses all over the place. They serve an additional function, as well, but I’m going to back-pocket that for the moment.

(If you find yourself thinking, “I know I’ve heard the term coin slot somewhere else before…” this SNL video featuring Lindsay Lohan and Kristin Wiig might jog your memory.)

Did You Have a Comment?

Most programming langagues–all the ones I have any familiarity with–provide a way to make comments in the code. These are lines that you tell the computer to ignore because they’re for human readers. In VBA, you start a comment with an apostrophe ( ‘ ) <– Hey! That kind of looks like a coin slot!

‘singleDouble Macro

The macro recorder automatically creates some comment lines at the beginning of each macro and fills in the macro name. Many programmers use comments to summarize what a piece of code does. For example, we might describe our subroutine as follows:

‘singleDouble Macro

‘Finds a period followed by a space and replaces it with a period followed by two spaces

The computer will see those apostrophes and just keep moving until it gets to a line that doesn’t start with an apostrophe–you know, like you always skipped every other page of those Great Illustrated Classics books. (That’s right. We know.)

Finally, Let’s Do Something

Now we get to the first line of the code that we can see makes something happen on the screen.

ShowVisualBasicEditor = True

Remember how we got that line in there? While we had the macro recorder running, we hit Alt-F11 to open the code editor.

code-editor

This line is formally called an assignment expression. The first part, ShowVisualBasicEditor, is the name of a property. The name exists within VBA. We didn’t make it up, and Word didn’t make it up. It’s part of the VBA language. Luckily, it’s a pretty easy-to-understand name.

The equals sign doesn’t technically mean “equals” here. It’s an assignment operator. And… veer off!

Some Terms

  • operation — I know you’re thinking of that poor guy with all the exposed bones and organs, but computers were built to do math, and a lot of their jargon comes out of the math world. A mathematical operation is what the rest of us generally refer to as “doing math.” 2 + 2 is an example of a mathematical operation of addition.
  • operator — Remember in elementary school when they taught you about the plus sign and the minus sign? Well, more official terms for those are the addition operator and the subtraction operator.
  • operand — The numbers in 2 + 2 are the operands, or the things that the operator acts on.

In the elementary-school-math context, the equals sign isn’t an operator. It’s just notational, not functional. In other words, the plus sign in “2 + 2 = 4” is actually making something happen. It’s joining two things. But the equals sign isn’t doing anything. It just shows up to tell us that the things on either side of it may look different but are the same.

In the computer programming context, the equals sign almost always is an operator.

To really get what’s happening here, you need to understand that ShowVisualBasicEditor is more like a variable than a number. Consider the following equations:

2 + 2 = 4

A + B = 4

In the first equation, everything is straightforward: we’ve got a couple of twos, and we’re joining them together. In the second equation, things are a little more abstract. We can set A to have any value 0, 1, 2, 3, or 4. We can then solve for B, or vice versa. In a very general way, that’s how ShowVisualBasicEditor is behaving here. There’s no reason you should know this without reading the documentation, but ShowVisualBasicEditor can either be true or false. That’s known as a boolean value. So the difference between “2 + 2 = 4” and “ShowVisualBasicEditor = False” is as follows:

  • When we write “2 + 2 = 4,” we’re not making a decision. It’s not as though sometimes 2 + 2 = 4 and sometimes 2 + 2 = 99. We’re not communicating that “Until I say otherwise, 2 + 2 = 4.” We’re saying, “There’s two ways to look at the number 4.”
  • When we write “ShowVisualBasicEditor = False,” we are making a decision. We’re saying, “ShowVisualBasicEditor can have one of two values: True or False. I don’t care what it was before. I’m assigning it the value of False now.”

That probably overexplains things sufficiently. It should be pretty obvious that if you set ShowVisualBasicEditor to False, the code editor closes. You can try it if you want. Copy that line of code and put it at the bottom of the macro, before End Sub. Change the True to False, save it (Ctrl + S), and then go back and click the button for your macro. The window opens up ever so briefly and then closes again. Blink and you might miss it. Dummary: Equals doesn’t always mean equals. In programming, most of the time something like “NameOfThing = ValueIWant” means “Find the thing this name refers to and assign it the value I want.”

Halfway There!

We’ve only examined one line very closely. Even if that didn’t all sink in yet, you get that we’re telling Word to either show or hide the code editor window by setting the property that shows the editor to either true or false. Well, take another look at our subroutine:

Sub singleDouble()
'
' singleDouble Macro
'
'
    ShowVisualBasicEditor = True
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = ". "
        .Replacement.Text = ".  "
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub

About half of the code looks almost exactly like the line we just analyzed. So now that you understand the structure of that line, you’ve got a good idea of what all we’re looking at here. Our macro is littered with assignment operations! Once we know what those different properties are, we’ll just be a couple lines from understanding the whole thing.

Before we get to those other properties, let’s make a quick visual connection. Go back to Word and click Ctrl + H to bring up the Find and Replace dialog. In the bottom left corner, there’s a button that says “More>>”.

moreButton

Click it to expand all the Find and Replace options.

f-n-r-all

Look at the options on the left. They’re worded a little differently except for “Match case” and “MatchCase,” but you’ll pick up on the correlation to some of our properties quickly. “Use wildcards” and “.MatchWildcards”, “Sounds like (English)” and “.MatchSoundsLike”, etc. If you don’t know what these properties mean, I’m leaving you in the hands of your favorite search engine. It’s clear that I love a good tangent, but we all have to draw an arbitrary line somewhere. I’m drawing mine here.

I am going to go a little deeper into wildcards in another post, but you’ll still want to do a little extra reading if you want to leverage them to their full extent.

What’s with all the periods?

So parentheses don’t mean the same thing in code as they do in regular writing. The equals sign doesn’t mean “equals.” Why would a period (or a dot) mean what it normally means?

In VBA, the period is a dot, and it’s an operator–it’s a dot operator. Think about our discussion of mathematical jargon earlier, and how that informs what you should expect out of an operator. First, an operator requires operands of some kind. These properties attached to the dots, then, must be the operands.

In some languages, the dot is called the access operator, which is a little more clear. The dots access things. Specifically, they access functions and properties. A visual might help here. Remember Inspector Gadget?

What am I thinking? Of course you do. If Inspector Gadget wanted to use his accessories, he usually uttered his famous catch phrase, “Go, go gadget…” and then the name of the thing. The dot operator is like the “Go, go gadget…” of programming. For example, the Inspector’s helicopter doesn’t exist by itself. It’s a part of the Inspector, as is his screwdriver. So if we wanted to rephrase Gadgetese into VBA, it might look something like this:

InspectorGadget.Copter

  You read the above phrase, “Inspector Gadget dot Copter.” Now look at the following line of code again:

Selection.Find.ClearFormatting

“Selection dot Find dot Clear Formatting.” So Selection has a gadget called Find, which has its own gadget called ClearFormatting.

To go back to some of the terminology we introduced earlier:

  • Find is a Property
  • ClearFormatting is a Subroutine

Selection is something new. It’s an Object. Objects in this context are easy to understand. In our example, Inspector Gadget is the object. His tools like the badge and flashlight are properties of Inspector Gadget. VBA translation:

InspectorGadget.Badge

InspectorGadget.Flashlight

 You should be starting to see the hierarchy. If the color of Gadget’s hair is a property of Gadget, then the color of his flashlight is a property of the flashlight. VBA translation:

InspectorGadget.Flashlight.Color

Both objects and properties can also have actions or work attached to them. For example, a flashlight shines when you push the button–but not until you push the button. In VBA, making the flashlight shine might look like this:

InspectorGadget.Flashlight.Shine

I’m sure you’ve cracked the code by now, but here’s one way to describe what’s going on in Selection.Find.ClearFormatting now that we have some jargon to talk about it:

  • Selection: An object that represents the text currently selected in your document. If you haven’t selected any text, it defaults to the entire document.
  • Find: A property of Selection that holds all the properties related to Word’s Find and Replace functionality.
  • ClearFormatting: A subroutine of Find. This particular sub tells Word to forget about looking at any formatting of the text and just concentrate on the characters themselves. (It’s possible, for instance, to search for the word “bold” only in bold format. The ClearFormatting command makes sure Word doesn’t do that. It sets all the formatting properties to False.)

The next line is also clear now, I hope.

    Selection.Find.Replacement.ClearFormatting

It makes sure we’re not using any formatting in our replacement term. When we replace the old period with a new one, the new one won’t be bold or italicized–though I challenge you to see the difference without some serious magnification.

But periods at the beginning of the line? Are they accessing a mysterious “Nothing” like the villain from The NeverEnding Story?

The next section has potential to be a little confusing, especially if you haven’t followed me thus far. If your head is already swimming, take a break before moving on. Maybe with some Oreos. Go ahead. I’ll wait…

Welcome back! Thanks for not sharing your Oreos, jerk.

At this point, you should understand that the dot or period in VBA is an accessor that calls gadgets (or, in more official programming terms, exposes properties). So what about these lines?

    With Selection.Find
        .Text = ". "
        .Replacement.Text = ".  "
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With

The dots are at the beginning of most of these lines. What are they accessing?

This is probably another spot where you’re already way ahead of me, because it’s in pretty plain English. Since I’m a dummy, I thought that the code was fancy and foreign by default. But we can apply the sandwich principle here again. Look at those first and last lines:

With Selection.Find

End With

Everything in between these two lines gets treated like it has Selection.Find at the start of it. It’s really just shorthand for what would otherwise have to look like this:

    Selection.Find.Text = ". "
    Selection.Find.Replacement.Text = ".  "
    Selection.Find.Forward = True
    Selection.Find.Wrap = wdFindContinue
    Selection.Find.Format = False
    Selection.Find.MatchCase = False
    Selection.Find.MatchWholeWord = False
    Selection.Find.MatchWildcards = False
    Selection.Find.MatchSoundsLike = False
    Selection.Find.MatchAllWordForms = False

You’ll find that programmers don’t like to repeat themselves. There are good reasons for this, and we’ll talk about them as we go. So even though we could just copy and paste Selection.Find for each line, the designer of the VBA language gave us a shortcut that saves us some grief in that respect. It also makes the code just a little more readable, which is also important.

So if you didn’t see it before, now it should be clear. We’re just setting 10 properties of Selection.Find, most importantly the text we want to find, and the text we want to put in place of what we find. As I said before, if you’re not sure what all of these properties are, you can google them. Or you can review Word’s help documentation on the Find and Replace function.

Hello, there, little macro. How do you do?

This leaves us with one more line:

Selection.Find.Execute Replace:=wdReplaceAll

Well, you know what the word execute means. So this is the line that actually sets action in motion. Up until this point, we’ve been telling Word what we want to look for and how we want to look for. Now we’re telling it to get started. Think of that moment in Snow White when the queen is giving orders to the huntsman. While she’s telling him to bring back Snow White’s lungs and liver (according to Grimm), nothing is happening yet.

Hunstman.CollectHerLiver = True

Huntsman.CollectHerLungs = True

At some point, the Queen has to tell the hunstman to go, otherwise he just sits there and listens to her talk.

Huntsman.GoGetHer

Our macro works the same way. It listens carefully as we explain what we want, taking notes.

Selection.Find.Text = “. “

Then when we give it the signal, it gets to work.

Selection.Find.Execute

And you probably already caught that the last piece there has the same effect as hitting the “Replace All” button on the Find and Replace dialog in Word.

Replace:=wdReplaceAll

The structure of this looks a little different from other things we’ve encountered. I’m going to explore that in more depth in another post–partly because this post is already plenty long, and partly because it’s a little out of scope.

A Dummy No Longer… about this, anyway

You know this macro like the back of your hand now, right?

So do you know why it’s not working the way we want? It’s doing exactly what we told it to–finding a period followed by a space, and then replacing it with a period followed by two spaces. But that’s the problem, isn’t it? Let’s look at it another way.

Find: abc

Replace: abcd

If we run that once on the text abc, we’ll get abcd. If we run it again, we’ll get abcdd. Again and we’ll get abcddd.

As soon as the computer finds abc, it recognizes a match and replaces the text. It doesn’t care that the next character is d and that it’s going to put two d‘s in a row, even if we don’t want it to. It’s completely obedient to the instructions we gave it. So in our use case with the period and spaces, we actually don’t want the computer to replace a period followed by one space with a period followed by two spaces. We want it to replace a period followed by a space and then any character that is not another space with a period followed by two spaces. If the period is already followed by two spaces, we want it to keep moving.

How do we do that? We’ll talk about that next!

Love and kisses,

Tyler

Mobile apps are awesome, but there’s always a “but”

If you’re learning to code because you want to build mobile apps, there’s a perspective on the current state of affairs that you should be familiar with. Jeff Atwood, one of the developers behind stackexchange.com and a pretty cool mechanical keyboard, has a blog that I’m really coming to enjoy. He published a post yesterday on some of the bigger problems caused by an increasingly massive mobile app market, including why it’s so frustrating for users–something app developers need to think about if they want their app to win over an audience and become profitable. It’s not a unique perspective, but Atwood is a good writer and articulates the problems well. Plus, it includes a couple of pretty funny cartoons.

Atwood’s post is apocalyptic, as its title suggests, and there’s no reason you have to agree with him. I think he’s pretty insightful, and I’ve gained a lot from some of his posts. Most of them aren’t for beginners, but this one should be accessible to anybody who’s used a smartphone for longer than about a day. Plus, who knows? You’re new to the coding game and not already invested in or bogged down by the existing infrastructure. Maybe you’ll be the one to solve the problems Atwood points out. But even if all you get out of it is a clear picture of the hurdles you have to clear as a mobile app developer, you’ll be a step ahead of a lot of folks who can’t be bothered to care. Like these guys:

Love and kisses,

Tyler

Learn to Code from Someone Else

If my pace isn’t fast enough for you, or if you just need more fodder for your insatiable hunger to learn everything you can about programming right this second, you might be interested in this post by Scott Hanselman that popped up on my radar today. It has a Venn diagram (or is it an Euler diagram? Are you nerdy enough to find out?) that explains the difference between some key terms like hacker, coder, developer, and, if you follow one of the links, dweeb. He also compares coding to going to Ikea, which is inaccurate. As miserable as coding makes me sometimes, it has never made me as miserable as a trip to Ikea.

I don’t have first-hand experience with all of the resources he points to, but I have used a few of them. The ones I know are good, and the others look like they’d be worth getting to know better. I noticed that Code, the book I mentioned in my first Learn to Code post, came up in Hanselman’s post, as well. That’s two out of two blogs connected to this blog that recommend that book! You can keep thinking about it if you want, but sooner or later, you’re going to read it. I’m as sure of that as I am that Oreos are going to get mentioned in this post.

One point Hanselman makes (that I made in a slightly different way and will echo here) is that where you should start learning to code depends heavily on where you want to end up–assuming you know where you want to end up. I’m trying to keep a pretty general view in my posts as I get started, since if you’re starting completely from scratch, there are basics that will come in handy no matter which direction you go. But if you already know that you want to build robots to reenact scenes from Saved By the Bell in your local community theater, you can probably find some materials elsewhere that will give you a foundation targeted more specifically toward that, and the list on Hanselman’s post is a good place to start.

Don’t forget about this guy!

So go ahead and browse around. There’s lots of good stuff out there. I’d love to hear some feedback on which resources you like best if you’re not coming at it from a STEM background.

Love and kisses,

Tyler

The Cheater’s Code: Recording Macros

Introduction

Remember, my target goal for these Learn to Code posts is non-programmers and non-computer science geeks. I’m trying to make as few assumptions as possible about your existing knowledge of programming and computer software in general. When I was learning programming, I needed something to fill in the dummy gaps, and my goal is to provide some of that for the folks who might be coming up behind me.

This post is heavier on abstract ideas than practical solutions, as I feel a need to explain why I’m offering a cheat first rather than following a more traditional route into the code. So get ready for some rambling! If you want to skip some of my philosophizing on programming tutorials and just get straight into recording macros, you can gostraight to the section under Microsoft Word’s Macro Recorder.

Scope of Application

Today’s post relies on Microsoft Word 2013 running on a Windows 8.1 machine. But what I’ll cover applies at least as far back as Word 2007 and Windows XP and the equivalent versions of Word for the Mac. If you don’t have Word, you can get a trial copy from Microsoft’s website.

Hello, World!

Most “Learn to Program” guides start with what’s called a “Hello, world!” program (HWP). These are minimal programs that get your computer to display the text “Hello, world!” on the screen. They’re designed as introductory learning tools. But somebody recently sent me this image about programming tutorials, and it reminded me of some of the challenges of introducing people to programming:

hello world draw an owl

Hello, World! Next step, build Google.

I’m no artist, but I can draw some circles… Ok, I can’t. My circles always turn out looking like ovals that somebody put in the microwave to see what would happen. But that’s lucky for you. If I could draw circles, what would the butterfly effect of that be? Probably wouldn’t be here writing this blog. So my sucky drawing skills say “You’re welcome.”

Anyway, I can draw deformed ovals. I’m also excellent at “Hello, world!” programs–as you undoubtedly will be. And I’ve got nothing against them. HWPs are great for doing something quick and easy in a new language, and I love instant gratification. It’s why I binge-watch TV and buy M&M’s at the gas station. (Nabisco, if you don’t sponsor my blog, I’ll buy more other things at the gas stations. Those M&M’s could have been Oreos.) But HWPs (Hello World Programs) aren’t as great introductions for total noobs as they’re sometimes thought to be.

To oversimplify, HWPs work best as an introduction to driving an unfamiliar car. “Hey, you know how in your car, the windshield wiper control is on the right?  Well, here, it’s on the left. And those stereo controls on the wheel? This car doesn’t have them. Oh, and the headlights aren’t on that lever on the steering column. There’s a button on the dash over there–yeah, that’s it.”

Any two cars have the same basic functionality, but the location of controls and how they’re labeled might vary greatly. And maybe one has heated seats and the other doesn’t. Programming languages are the same way. They share an incredibly long list of basic functions, but the names of those functions and how you access them can seem worlds apart at first glance. And every language has its own set of bells and whistles. Imagine, though, that you’ve never seen a car before, or that what you really want to understand is how turning that knob on the lever sticking out of the steering column makes the windshield wipers move. You would be looking for a different entry point to the conversation.

It’s unfair to say that all HWPs are sub-par introductions to first-time programmers with no computer science background. But how are those noobs supposed to recognize the difference between an HWP that will appeal to someone starting from scratch and one that is built for experienced users transitioning to a new language? Tutorials are getting better at identifying prerequisite knowledge or experience, but I think the inspiration for the owl cartoon above is the vast majority of tutorials that take a reader’s knowledge for granted. For self-starters who don’t have a mentor or a safe space to ask questions, those tutorials can be a huge turnoff. They make programming seem as mysterious as quantum physics or the rise of bronies.

I’ve done my fair share of HWPs and still do. They’ll always serve the appropriate audience well. But I found a side door into the code that was really instructive for me. It’s cheating, for sure. But it was the best learning tool I could have asked for: recording macros. It won’t land you a job at Amazon or anything. (Trust me. They were not at all impressed with my macro skills when I interviewed there.) But it will give you a leg up if you have a mind like mine–and I’m assuming you do, or else you’d be out doing an HWP in Python right now.

Macros

You’ve heard of macros, right? Some nerd at your office or in one of your classes makes their own macros or downloads them from the internet. The term macro can actually be applied to certain structures of computer code in general, but they’re most commonly associated with Microsoft’s Office suite of programs–especially Excel.

We need a quick definition of macro for our discussion, so I’m going to say you can think of a macro as a recipe. Say we have a macro called “Peanut Butter Sandwich.” We write the step-by-step instructions for making the sandwich only once. From then on, any time we want the computer to make a peanut butter sandwich (which should probably be the ultimate goal of computing), we just say “Peanut Butter Sandwich.” The computer then reads that recipe and does each of the steps.

Dummary (dummy’s summary): As long as we know the recipe’s name (macro name), we can prompt the computer to do all the steps in the recipe just by telling it the name.

Wait, wait, wait… I hear software developers referring to themselves as JavaScript Ninjas and Agile Samurais–or the less cool sounding but still endearing “Code Monkey.” You make it sound as if they’re more like a bunch of Julia Childs… Julia Children?… Rachel Rays.

Umm… I think there’s a healthy middle ground:

Chef Louis from Disney’s The Little Mermaid

Microsoft’s Office suite has a set of tools that allows you to create your own macros to automate tasks you do over and over again. But instead of having to write the recipe, you can record it. The software will then let you name your recipe and designate a way to call it up and tell the computer to follow it.

Microsoft Word’s Macro Recorder

More and more tools are emerging that demonstrate code in action in real time, but the one that really served me starting out was Microsoft Word’s macro recorder. It’s actually pretty awesome, and if this is the closest you ever get to programming, it will be a big value add in most professional environments. Excel and PowerPoint have the same tools, but I’m going to focus on Word for now.

Recording macros is easy, but before you can do it, you have to give yourself access to the macro tools by turning on the Developer tab in the ribbon.

Your ribbon in Word should look something like the screenshot below. I’m using Word 2013, so the style of yours may be different, but the content should be more or less the same.

word-ribbon-std

We’re going to click the File tab, and select “Options.”

file-tab

In the dialog window that pops up, select “Customize Ribbon” from the panel on the left:

customize-ribbon

When those options load, you’ll see a box on the right with a list of all the tabs. All the ones with check marks by them are on and available when you open Word. Anything without a check mark is turned off.

cuztomize-ribbon-tree

Just past the halfway point on that list, you should see the value “Developer,” and unless you’ve already been fiddling with macros, the box next to it is probably not checked. Click the checkbox or the word “Developer” to turn it on:

developer-clicked

Click the “Ok” button on the dialog window, and now you’ll see the Developer tab in your ribbon:

developer-tab-appear

Go ahead and click on it to open it up. It should look something like this:

dev-tab-std

There’s a lot here, but we’re going to concern ourselves only with the Code group on the left:

code-group

Quick diversion

In case you’re not familiar with the terminology of Word’s thingamajigs, here’s a quick review:

  • That big bar along the top that showed up around 2007 is the ribbon. If you used Word before then, you were mad about it for at least a couple years. If you didn’t get to college before 2008, you don’t understand what all the fuss was about. You also don’t know who Clippy is and why this clip from NPR’s Wait Wait… Don’t Tell Me! is hilarious.
  • The ribbon is divided into tabs, which is pretty standard currency. You’ve got a grip on that.
  • The tabs are divided into groups, which are usually separated with a vertical bar or pipe. On the Home tab, for example, the three left-most groups are Clipboard, Font, and Paragraph. See those vertical bars in between?

sample-groups-pipe

That’s where one group ends and the next begins. Some of them are a little arbitrary, but most of them make sense.

  • Within the groups are controls. Every little button and dropdown is a control.
  • Dummary: When you click the big bold B to make text bold, you’re using the bold control within the Font group on the Home tab of the Word ribbon.

Back on Track

You see where this is going. There’s a record button staring you in the face.

Don’t Write Code. Watch it Happen!

When I was first learning to code, I read a lot of sample programs. We’ll talk about that more later. The problem is that programs of any complexity get unwieldy pretty quickly. Sophisticated programs require sophisticated setup. So even when I wanted my code to reproduce existing actions in a program like Word, I didn’t know how to find that particular action in sample code. I kept thinking, “What if I could just see the code for what I’m doing right now separate from everything else?” Turns out the macro recorder makes that possible. It has some limits, of course, but it let’s you essentially watch code being built.

First, write or copy a couple of paragraphs in Word. I borrowed mine from Don Quixote, because it keeps coming up and I’m trying to remind myself that I should read it.

I’m going to keep this really simple. When I was working in the document production department of a law firm, one of the things we constantly came across was a difference in preferences among the lawyers about whether they wanted one or two spaces after a period. I’m a one-space-after-the-period kind of guy. I have my reasons, but I’ll save that discussion for when we meet at a dinner party somewhere. Cuz that’s the best dinner party conversation I have. I don’t want to use it up here.

You probably already know that Word has a Find and Replace feature. You just hit Ctrl + H, and that little box comes up.

f-n-r

I put a period and a single space(“. “) in the Find box and a period followed by two spaces (“.  “) in the Replace with box, click Replace All, and the work is done. Yeah, if there were abbreviations like “Dr.” and “Ms.” then I have to go back and fix a few things. I’m going to get to that in a later post. Suffice it to say for now that this couldn’t be much easier.

Here’s the rub: I know that I’m potentially going to do this 100 times a week. While hitting Ctrl-H and typing a couple periods and a few spaces only takes a few seconds, I also make the occasional typing mistake. Plus, 3 seconds 100 times a week is 300 seconds. That’s 5 minutes a week, 50 weeks a year… Over 4 hours! That’s 4 x my hourly rate every year to have me do something that the computer could do almost instantly if I had a button for it.

That might seem ridiculous, but if you’re part of a mid-sized or large organization, some number cruncher somewhere is doing calculations like that, or they’ll hire some Six Sigma black belt to come do it when they want to improve efficiency. Thinking about these things is also how you add business value. “Hey, boss, if you let me implement this solution with my team, it’ll cost you nothing and save you $2,000 over the next 5 years.” (Yes, on a team of document production folks in a mid-sized company, a simple macro could theoretically save a company that amount of money over that range of time. No joke. Of course, few custom programming solutions cost nothing. This is pretty unique ROI.)

So how do I take this one task and turn it into a macro? Record it.

Record Your First Macro

On the Developer tab, click the Record Macro button.

record-macro-button

A Record Macro dialog will come up asking you to name the macro and assign it to a button or a keystroke. For now, just give it a name and click Ok. I’m going to walk you through how to add it as a button later. Your pointer now has a little cassette tape attached to it, because recording stuff used to have something to do with magnetic strips inside plastic cassette cases. Look it up, kids.

cassette-mouse

The record button also has changed to a Stop Recording button, and the Pause Recording button is clickable:

stop-recording

The first time I did this, I thought time mattered. Why else would there be a Pause button? Turns out that your macro recorder doesn’t care how much time you spend doing anything. It doesn’t track time; it only tracks actions. So while you’re reading this paragraph, Word isn’t recording anything. The time between when you hit the Record button and when you actually do something it will record won’t be part of the macro.

The Pause button tells Word to ignore actions. You can leave out stuff you want to do now but that you don’t want the macro to repeat in the future.

You could just go straight into recording the macro, but I want you to see some of the magic happening, so hit Alt + F11. This opens up a code editor that looks something like this:

code-editor

We’ll look at all the bells and whistles later. Right now, look for a window on the left that says “Project – Normal” at the top. This is the Project Explorer Window. If you don’t see it, press Ctrl + R.

Within that window, you should see a selection tree that looks something like this:

normal-tree

Double-click the label “NewMacros.” Don’t worry about that weird symbol next to it for now. A text editing window opens up with the code for your macro.

macro-code

See how it has the name “singleDouble” at the top? It’s calling it a Sub, which, again, we won’t worry about for right now. (“Don’t worry about that right now” is a mantra for all Learn-to-Code tutorials. There’s just no getting around it.)

The line that’s in there right now, “ShowVisualBasicEditor = True”, was recorded when we opened up this code editor. Next time you run the macro, it’s going to do that again. You can erase it if you want. I’m going to leave it in mine for now.

Leave that window up where you can see it, and go back to your sample document in Word. Press Ctrl+H. Nothing happens in your code window. Don’t worry. It’s still recording.

Enter your find and replace terms: period followed by one space (“. “) and period followed by two spaces (“.  “).  Still, nothing happens in your code window. I promise it’s still recording. Your cassette is still there.

Click Replace All and then clear any dialogs that come up. Did your code window just fill up?

code-after

Yeah it did. In the next post, I’m going to go over all of this in excruciating detail. Right now, I want you to go back to your Developer tab and hit Stop Recording.

You did it. You recorded a macro. But I stopped you from assigning it to a button or a keystroke earlier. So you can’t run it again without going into this code editor, pulling it up, and hitting the play button in there.

play-button

Crud. Ok. I’ll show you how to add a button to your Quick Access toolbar, but then I’m folding laundry and watching Downton Abbey.

Your Quick Access toolbar is that strip of buttons that resides just above or just below your ribbon, depending on your preferences. I keep mine below the ribbon. Yours may look a little different than mine, but it will have small icons and a little down arrow on the far end of it:

quick-access

Click that arrow and select “More Commands…” from the menu that appears.

quick-access-customize

Your Options dialog comes up focused on the section for customizing the Quick Access toolbar. The column on the left is all the things you can choose from, and the column on the right is all the stuff currently in your Quick Access toolbar.

options-cuztomize-quick-access

Find the dropdown above the column on the left labeled “Choose Commands From” and select Macros.

choose-commands-from

Unless you’ve got some extra add-ins or other custom tools installed, the only thing in the list should be the macro you just recorded.

your-macro

It’s got a weird symbol next to it and a longer name than you thought you gave it, but that’s definitely it. Hit the “Add>>” button to include it in the Quick Access toolbar, and then click Ok. A button for your macro with that weird symbol should now show up on your toolbar.

quick-access-with-newmacro

Click it! Click it! Then click it again! And again! You’re excited!

Uh-oh… Every time you run it, it adds more space between the period and the next sentence. This is not exactly what we wanted. But there’s some good news here, too. Even though it didn’t do what you wanted it to, or what you thought it would, it did exactly what you told it to. It works! You pushed a button and made something happen that Word didn’t do on its own. You’re a (cheater) programmer!

This might be a little frustrating, but I’m going to end this post here and leave you with a couple challenges. First, figure out why the macro keeps adding space. Then, see if you can fix it. In the next post, I’m going to keep my promise and elaborate on the code in detail. I’m going to really drag it out and fill in the dummy gaps.

It’s about to get fun. Programming is problem-solving. That’s the primary aim. And it’s mostly about solving problems you didn’t expect, like this one. If you figure it out between now and the next post, leave your answer in the comments. I’ll be back soon with my answer.

Love and kisses,

Tyler

OTRS Config Part III: The Admin Interface and Common Tasks

Introduction

This will be the last of my planned posts on OTRS configuration. If you missed Part 1 or Part 2, be sure to check them out.  This post covers more concrete tasks and is less concerned with the abstract ideas covered in the first two posts. The content here was prompted by particular business needs, but based on my experience so far, it should have a pretty wide scope of application. Speaking of which…

Scope of Application

The descriptions and screenshots in this document were generated for and from a Linux system with the following setup:

  • CentOS 6.4 or 6.5 | OpenSuSE 13.1
  • MySQL 5.1.71
  • OTRS 3.3.3 | OTRS 3.3.4
  • Apache 2.2.15 (Unix)
  • Viewed with Firefox 26

You might want to install a similar setup to follow along. But you can do all the same things on a Windows or Mac.

Admin Interface

The majority of the system configuration you do will be through the Admin tools in the OTRS web interface. This includes tasks we’ve already reviewed, like creating Groups, Roles, and Queues; assigning permissions; and associating different elements. OTRS has a relatively sophisticated set of administrative tools. The relationships of the various modules will take time and practice to master, but they are ultimately quite simple to navigate.

The one possible exception is the SysConfig interface, which we will look at next. Once you understand how it organizes the configuration modules, you will be able to take advantage of its power and convenience.

SysConfig

Much of the configuration of OTRS can be done through the SysConfig interface. Access the SysConfig interface by logging into OTRS and clicking the Admin tab. (If you do not have Admin access in OTRS, you will not see this tab.) SysConfig is in the System Administration group.

system-admin-tools

When you first open the SysConfig, there’s not much to see. The default view shows no modules. You begin navigating using the Actions sidebar on the left.

actions-sidebar

You can type specific terms into the search field, or you can filter by config groups. These groups take a little getting used to. As you get more familiar with the naming conventions used by OTRS, navigating to specific modules and properties via the config groups will get easier. The nice thing about OTRS being so popular is that you can find a lot of help online. (Note the self-fulfilling prophecy I just made!)

Before we get to looking at any of the modules, let’s Export the current settings.[1]

Exporting and Importing Settings

It is important to get into the habit of exporting the configuration settings before you make any changes—and especially before importing another collection of configuration settings.

Click the “Export Settings” button. You should see a dialog prompting you to save a Perl module file

sysconfig-backup-dlg

Save the file somewhere that you can access it easily.

To import settings, click the “Import settings” button, browse for the file, and click “Submit.”

Module Access

Turn off Agents < – > Groups Assignments

Out of the box, OTRS allows you to assign Group rights directly to individual Agents.[2]

agent-mgt-tools

We’ve already reviewed the reasons that motivate us to assign Agent rights through roles exclusively. To enforce compliance with this policy, we can turn off access to the module that allows us to associate Agents directly with Groups.[3]

Note that turning off access to the module is not the same as disabling it. Any Agent-to-Group associations that have already been made will still be in place. Also, any action that redirects to the Agent-to-Group assignment will still be able to reach the module. The primary advantage of turning it off is that it eliminates accidental clicks and the amount of options you have to process as you perform administrative tasks.

Follow these steps to turn off the link:

  1. Navigate to the SysConfig interface.
  2. Select “Framework” from the dropdown on the left.

    sys-config-drpdwn

  3. Locate the module Frontend::Admin::ModuleRegistration and open it.

    frontend-admin-moduleregistration

  4. Locate the property Frontend::Module###AdminUserGroup.

    adminusergroup-chk

  5. Uncheck the box next to this property.

    adminusergroup-unchk

  6. Scroll to the bottom of the page and click Update.
  7. To make sure you’ve turned off the link, go back to the Admin interface. You should no longer see “Agents < – > Groups” under the Agent Management settings.

    no-agent-group

Redirection

It is possible to change the workflow routes of OTRS, helping to prompt users through the experience they prefer.

Set the page Customers see at login

By default, when customers log on they see an overview of their open tickets. If that’s what your customers are used to, that’s great. But many customers are used to seeing a ticket entry screen when they log on to their help desk. To ease the transition to OTRS for these folks, we would want to preserve that experience.

  1. Navigate to the SysConfig interface
  2. Select “Ticket” from the dropdown on the left
  3. Locate and select Frontend::Customer
  4. Locate CustomerFrontend::CommonParam###Action. By default, this is set to CustomerTicketOverviewcustomerfrontend-action-overview
  5. Change the value to CustomerTicketMessagecustomerfrontend-action-message
  6. Click “Update”
  7. Log into the Customer portal to confirm that you are redirected to the new ticket view by default

Tip: You can often find out the name/value of a particular view by visiting that page and examining the URL

customerticketmessage-url-detail

Changing the Appearance of OTRS

Change the Headline and Logo

default-headline                                                                          default-logo

OTRS uses its own logos and icons by default. Wouldn’t you? To place your own brand on the environment, you need to change the headline and logo. First, you’ll need an image. The OTRS blog recommends that the image be 135 x 50 pixels, but you can figure out the best size for your image through experimentation. In our case, let’s assume the image is named HelpBrand.jpg.

  1. Place the image in $OTRS:var/httpd/htdocs/skins/[Agent | Customer][4]/default/img
  2. Navigate to the SysConfig interface in OTRS
  3. Select “Framework” from the dropdown on the left
  4. Locate and select Frontend::Customer
  5. Change CustomerHeadline from “Example Company Support” to your desired text
  6. Find the group of CustomerLogo settings and change the URL to skins/Customer/default/img/HelpBrand.jpg
  7. Click “Update”
  8. Navigate to the Customer portal. You should see your changes reflected there
rocky-logo

This help desk is gonna fly now!

dummy-logo

To change the logo on the Agent side, adjust the corresponding AgentLogo settings in Frontend::Agent.

Ticket Settings

This section covers different ways to change what users and agents can and must input when filling out a ticket.

Make Time Units Mandatory

Agent tickets have time accounting turned on by default, but it is not a required field. Many organizations want time accounting to be required. Here’s how to do that:

  1. Navigate to the SysConfig interface
  2. Search for “time units”
  3. Depending on what packages you have installed, you may see only see one result here: Frontend::Agent. If you have the iPhone module installed, you will see more results. Select the subgroup “Frontend::Agent” in the group “Ticket.”
  4. There are a couple dozen settings here. You can use Ctrl + F to search for “time” or “account.”
  5. Ticket::Frontend::AccountTime should be set to “Yes”ticket-frontend-accounttime
  6. We are specifically looking for “NeedAccountedTime.” OTRS uses “Need” as a keyword to indicate that a field is required.[5] By default, this is set to “No.” Change it to “Yes.”ticket-frontend-accounttime-drpdwn
  7. Click “Update”
  8. Create a new ticket as an Agent by clicking Tickets>New Email Ticket
  9. Scroll down until you see the “Time units” field. It should have a star by it and be in black text instead of gray.

time-units-rqd

Add a New Ticket button to the customer interface

Out of the box, OTRS includes the “New Ticket” button in a dropdown menu in the Customer’s Ticket Overview interface.

new-ticket

While this may be accessible enough and intuitive to the vast majority of users, the dummies like me need a button that they can access a little more directly. Otherwise, we spend the first couple of weeks filling out phone request tickets for how to access the New Ticket button.

  1. Navigate to the SysConfig interface
  2. Choose “Ticket” from the dropdown on the left
  3. Find and select Frontend::Customer::ModuleRegistration
  4. The first group of settings is CustomerFrontEnd::Module###CustomerTicketOverview. This defines what the customer will see in the various menus and submenus throughout the customer interface. We’re going to stay within the CustomerTicketOverview section, but I recommend that you look over all of these settings and get familiar with them.sysconfig-customerticketoverview
  5. Notice the NavBarName property. By naming the NavBar, we are able to group and order actions, as well as persist a single NavBar across views.
  6. Scroll to the bottom of the NavBar entries, for CustomerTicketOverview. If you’ve made no changes, there are two of them: “Tickets” and “My Tickets.”
  7. Find the plus sign after the last entry, and click it.sysconfig-customerticketoverview-detail-filled
  8. The page will reload and give you an empty set of parameters. Fill them in as follows:
    • Description:       New Ticket
    • Name:                   New Ticket
    • Link:                      Action=CustomerTicketMessage
    • Priority:                90
    • AccessKey            n
  9. Click “Update”
  10. Log into the Customer portal. You should now see the “New Ticket” button in the NavBar

new-ticket-button

Dynamic Fields

Dynamic fields are how you gather information the developers of OTRS either didn’t think about or didn’t care about when they designed the system. Every organization has their own interests, and OTRS provides the flexibility to customize what data you’re tracking and presenting. We’ll look at one example: adding a branch name to a ticket. Warning: This is a long one! Adding dynamic fields and confirming they work takes quite a bit of setup.

Add a Branch field to the ticket

  1. Navigate to the Dynamic Fields Management interfaceticket-settings-tools
  2. Select “Dropdown” from the Ticket dropdown on the left.dynamicfieldsmanagement-overviewticket-dropdown
  3. Fill out form with the following details:
    • Name:             ddBranch
    • Label:             Branch
    • Field order:    1 (don’t worry about replacing anything that’s there)
    • Validity:         Valid
  4. Click the plus sign next to Add valueadd-value
  5. Set the Key to “101” and the Value to “Support Group”
  6. Set the Default Value to “Support Group”drpdwn-settings-supportgroup
  7. Leave the remaining settings as they are, and click “Save”
  8. Your new Dynamic Field should appear in the Dynamic Fields Listdynamic-fiels-list
  9. Navigate to the SysConfig interface
  10. Choose “Ticket” from the dropdown on the left
  11. Find and Select Frontend::Customer::Ticket::ViewNew
  12. Find Ticket::Frontend::CustomerTicketMessage###DynamicFieldticket-frontend-dynamicfield
  13. Click the plus sign
  14. Enter the key of your Dynamic Field (in this case “ddBranch”) and set the Content value to 1 (Enabled)key-content-filled
  15. Click “Update”
  16. Go back to the SysConfig interface
  17. Choose “Ticket” from the dropdown on the left
  18. Find and Select Frontend::Agent::Ticket::ViewZoom
  19. Scroll down to Ticket::Frontend::AgentTicketZoom###DynamicField
  20. Click the plus sign.
  21. Enter the key of your Dynamic Field (in this case “ddBranch”) and set the Content value to 1 (Enabled)
  22. Click “Update”
  23. We’re almost finished, but we need to make sure that OTRS displays the entire value of the field without truncating it. So go back to the SysConfig interface one more time
  24. Choose “Ticket” from the dropdown on the left
  25. Locate and select Frontend::Agent
  26. Locate Ticket::Frontend::DynamicFieldsZoomMaxSizeSidebar
  27. The default value is 18 characters. Set it to 140 (or whatever length you know you need)fields-zoom-max-sidebar
  28. Click “Update”
  29. Log into the customer interface
  30. You should see your  new field at the end of the default fields with your default value selectedbranch-dropdown
  31. Fill out and submit a test ticket
  32. Log into the Agent interface
  33. Locate and open your test ticket
  34. You should now see your Dynamic Field in the Ticket Information sidebar

branch-test-ticket

Conclusion

I’ll continue to use OTRS and so may come across something new to share from time to time, but this ends my original trilogy of configuration posts. OTRS has plenty more features to explore, but we’ve covered all the major bases.  If you followed me this far, you should be able to tackle quite a bit more on your own. Feel free to use the comments here to drop a line and ask me questions. If there’s any way I can lend a hand, I will.

Love and kisses,

Tyler


[1] Technically, OTRS actually stores all of its default settings. Anything you change in the SysConfig can be reset to the defaults pretty easily. Backing up the settings will become increasingly important as you customize the environment further.

[2] If you are not sure what Group rights are, review the OTRS documentation on Groups.

[3] Of course, the System Administrator will always be able to turn access to this module back on, but removing the option from plain sight will help us avoid mistakes.

[4] [Agent | Customer] should be read as “Agent or Customer,” and indicates that you will need to put it in each of the directories. The tree structure is otherwise the same. In the example, we’ll be changing the image on the Customer side.

[5] OTRS also sometimes uses the word “Mandatory” instead of “Needed.” See Ticket::Frontend::CustomerTicketMessage###ServiceMandatory.