Tap Forms JavaScript Scripting 101
by T. L. Ford

Section 1: Introducing JavaScript and a Line of Code

Programmer buzzwords are introduced like this. Every industry has its own language. Programming has many languages with some common descriptive terms. You only need to learn a few to make Tap Forms scripts.

Tap Forms scripts are written in JavaScript. That's the language you write in and include when searching on the Internet for how to do things. The good news: JavaScript has been around a long time, is extremely well-documented and has many examples. The bad news: you'll find some bad examples and examples that apply to websites that aren't helpful for Tap Forms.

JavaScript looks like English. It is NOT English. It is a high-level programming language (easy for humans to read/write) that the computer reads through and does what it says.

JavaScript has very specific syntax (keywords and punctuation that mean very specific things). Computers are dumb and get confused if the punctuation is wrong, or if you try to use one of the keywords for something else, or if it doesn't know a word.

See this line of JavaScript that appears in a newly created Tap Forms script:

var hello_world = "Hello World!";

This looks vaguely like English, but it isn't. This is how the computer is going to read it:

var - Ok, var is one of my keywords and I know what to do with those. The var keyword means that you are declaring (telling me about something) a variable (a name you want to use to refer to that something in this block (some grouped lines) of code (the JavaScript). Similar keywords are let and const.

hello_world - This is the variable name. I know that because it is one word, no spaces, and it came immediately after the var keyword. That underscore is just part of the word. I'll add this to my language dictionary.

Next, I expect to see a ; or an =. If I see a ;, that means you'll tell me what is in this variable later.

= - Ah, good, you are going to tell me what to put (store) in this variable so I can give it back to you later. Otherwise, I would have stored undefined (a default value that means you haven't given me anything).

" - Whee, a quotation mark. That's the beginning of some text (a string). So everything up to the next " is your stuff (data).

Hello World! - I'm just going to take this stuff and hold onto it for you in the variable named hello_world.

" - this second quotation mark told me that was the end of your string.

; - semi-colon, my *favorite* symbol in the whole wide world that gives me joy and happiness and tells me that's the end of this instruction. Forgetting to give me a ; is the number one mistake new programmers make.

I know that's an awful lot of interpretation for one simple line of code, but don't despair. There aren't too many things you're going to need to know to write Tap Forms scripts.

This is how an entry-level programmer is going to describe this line:

var hello_world = "Hello World!";

This stores the string Hello World! in the variable hello_world.

An expert programmer is going to squint at you and not understand the question, because their brain has hard-wired neurons that no longer see this. An example: if you're an experienced car driver, you see the speed limit sign as you are driving to work and it's clearly an instruction, but you no longer see it. You just know it's there and automatically apply that knowledge.

This is why I told programmers to skip this tutorial - they're going want to pontificate on pointers and memory allocation and scope and String being an object vs string being an array of characters terminated by a \0. They're an odd lot who are ruled by very specific definitions and have a tendency to point out if you have ignored the nuances of a word or (gasp, horror!) misused a word or, in this tutorial's case, oversimplified a word.

I'm just going to tell you enough so that you have a foundation and I'm going to say it in a way that makes sense. You can learn and ponder the specific details and nuances once you have the concept down.

var hello_world = "Hello World!";

This line of code creates a new JavaScript temporary term (hello_world) that stores something you can get and use or change later. You use that new word to get back whatever the computer has memorized for you, like a memory button on a calculator or a suitcase full of clothes. This is called a variable. A variable is a word that you just added to the computer's language that has something in it like a suitcase has clothes in it. (A programmer somewhere has just cried out in agony and doesn't know why.)

NEXT - Section 2: Code Comments