

TextExpander.appendOutput("The assignment due date is " + "%filltext:name:Enter the due date of the assignment%" + ".") TextExpander.appendOutput("The instructor is " + strInstructors + ".\n") TextExpander.appendOutput("The assignment is " + "%filltext:name:Enter the name of the assignment%" + ".\n") TextExpander.appendOutput("The student is " + "%filltext:name:Enter the name of the student%" + ".\n") TextExpander.appendOutput("The course is " + strCourse + ".\n")
TEXTEXPANDER JAVASCRIPT CODE
If you want to download all these snippets and import them in TextExpander directly, you can follow Download snippets group.The code I put together for this example snippet is as follows: let strCourse = "%fillpopup:name=Select a course:Calculus:Trigonometry:Statistics:Logic%" In this article I presented some snippets I found useful for my daily job, but I’m sure that many other could be written on more specific needs. Managing lists with TextExpander on OsX and iOS let you save time by cutting off repetitive tasks. As you can see it’s super easy: var out = "" Last script enumerate each line of a list starting from zero. Out += row.substring(0, row.length-charToDelete)+"\n" Īs told before, if you don’t mind to keep the compatibility with iOS, you can use a fill-in in your snippet to specify the number of chars you want to remove at “expanding-time”, but it’s out of scope for this post.

… and the one to remove N chars on the left: var out = "" Out += row.substring(charToDelete, row.length)+"\n" So here’s the cod for removing N chars (depending by the abbreviation) on the right… var out = "" Sometimes it happens that you need to remove the first of the last X character for each line of a list.ĭoing that is super-easy with TextExpander but if you want to write a snippets capable of running on OsX and iOS, unfortunately you need to write a snippet for each value of X: infact TextExpander for OsX does not support text fill-ins, so you cannot pass a parameter to the script.īut an interesting trick could be rewrite the snippet in a way it gets the number of chars to delete from the last character of the abbreviation: doing that you can’t skip the problem of creating multiple snippets, but you can copy always the same code changing only the abbreviation according to your needs (e.g.

This script simply transform a multi line text in a “one line” text by removing the “\n” char at the end of each line and using “,” as a value separator. isNaN that it returns true even if you specify a number within quotes due to Javascript implicit casting. isNaN method to check if the value is numeric or not and then use or no quotes but I don’t like this idea because very often I put numeric values in text fields, so I prefer the script to output always with quotes and maybe then delete them manually. If you want you can modify the script by using for example. The script is very simple and, beside transforming each lines, it also remove blank lines and trim spaces. Here is the code if you need to copy it, and at the end of the article I will link the exported TextExpander group with all the macros. What you have to do with TextExpander is to write a snippet like this: Then you can use the transformed list in a SELECT … WHERE x IN.
TEXTEXPANDER JAVASCRIPT PLUS
Generally you have to take each item of the list (or row of the text if you prefer), add one single quote at the beginning, one at the end, plus a comma for each line and open/close brackets before and after the text. This first snippet becomes handy when you have a list you want to use in a SQL (for example a SELECT or an INSERT). The idea at the base of all the snippets is to do some transformation with a list rapresented by a multiline text copied in the clipboard.
TEXTEXPANDER JAVASCRIPT MAC
In this post I will present you few snippets I use more on Mac and on the iPad, and some trick to implement more of the same type. The last version number 5, launched in May, allows you to run on both OsX and iOS Javascript scripts inside snippets: it means that using TextExpander custom keyboard, you can run Javascript from within every application on every supported device. TextExpander is a great utility I use on a daily basis to manage text snippets on my Mac and, thanks to the builtin synchronization mechanism, my iOS devices.
