Archive
QuickTip: Loading Files to PlaceGun
After long time here comes new post about InDesign scripting! 😀
This one is really cool and handy. Simply select files and script will load them directly into PlaceGun tool! Really simple and handy! Also there are some options that you can set while loading files into PlaceGun, but we will just focus on simple loading. One more thing. InDesign CS5 DOM introduced new class that is directly connected to PlaceGun. It has some more options like: abortPlaceGun and rotate among others. So, let’s get started! 😀
QuickTip: Calculate Script Execution Time
Building some complex script, have multiple variations of same part of the script, and want to know which one is faster? This little function is perfect for you! Take a look! 😀
QuickTip: Check if a number is between two numbers
In JavaScript I always miss one great feature from MySQL and that is operator between. It checks if a number is between two numbers you enter. So I decided to create small ‘Number’ prototype to achieve this. If a number is between is between then it returns true, and if not returns false. It’s perfect for using in ‘if()’ statements.
QuickTip: Check if a number is even or odd
How to check if a number is even or odd? We can use Modulus operator (%), which returns the remainder of a division operation. If you divide some number by two, a remainder of 0 indicates an even number, while a remainder of 1 indicates an odd number. Best and easiest way is to create ‘Number’ prototype.
Great Javascript Assignment Operators
There are few Javascript assignment operators that we are already using, and they are really handy. We will just go through some of them really quickly just to refresh our memory 🙂 So, let’s start!
Convert Decimal to Roman and back
Few days ago, on Adobe’s InDesign scripting forum I found something very interesting. It was great little function for number conversion from Decimal to Roman numbers. But it wasn’t I enough so I tried to reverse functionality. Functions are converted to ‘prototypes’ for easier usage. 😀
Rounding numbers in JavaScript
Very often we need to round some numbers, and Javascript has function to round numbers, but sometimes it’s not working very good. Luckily we can round number through math functions. First, let’s see how to use built-in Javascript functions. This script was also published on Adobe’s InDesign scripting forum. I collected some more info’s and combined them all into this post.
Search inside array
With this script we can search inside Array. This is not quite InDesign snippet and can be used in every Javascript. I really like approach to search problem, and want to share it with you. Script is not mine, I just found it on web long time ago.