PaperCut Print Script of the Month #3 – Random Quote

PaperCut print script – Random quotes


After all of the fun from the holidays we have decided to keep this month’s PaperCut print script simple so we can let the mince pies properly digest, this month we are showing users random inspirational / motivation quotes.

So let’s grab a cup of coffee or tea if you don’t like the good stuff and let’s get started. Our print script this month will make use of an array and a couple of Math methods that are available to us in Javascript.

An Array is a handy way to store multiple values in a single variable each of the values will have an index (number) assigned to it so we can reference it later, It might be easier to think of this like the track listing on your favorite album (Origin of Symmetry by Muse if you wanted to know) where each song has it’s own number.

So to create our array we will create a new variable and assign some values separated by commas:

So now we have an array that contains 5 values and we need to return one of them, There is a bit of a trick to this as computers start counting from 0 so get the value “Hello” back we would need to use quotes[0] and to get “World” we would need to use quotes[1]. As covered in a previous print script we are using to use the actions.client.sendMessage() method to show our values.

As a quick test you could use something like the line below to send a message to the user:

But that would be to simple and wouldn’t be random at all so lets look at the first of the Math functions. Math.random() will return a pseudo-random number between 0 and 0.999999 now for those who have noticed we have 5 values in our array so the number generated is not going to help us. This is where we use a method array called Length this will tell us how many values are stored in our array so we just multiple Math.random() by that and end up with the line below:

Now this gives us another problem as we would be looking for an array index that is between 0 and 5.999999 and this is where our last Math method comes into play. Math.Floor() will round our number down to the nearest whole number so 0.123456 would become 0 and 5.999999 would become 5. Now we have everything we need and our sendMessage line will end up looking like this:

All that is left to do is fill your quotes array with any quotes you can find on the internet and you are good to go. Hopefully this helped you understand Arrays in print scripts and given you an idea you can use to help inspire or motivate your users.

As always the complete PaperCut print script is below and if you have your own requirements for a print script and you don’t have the time or in house experience to make it you can find out how we can help you by sending an email to our sales team at

PaperCut print script
Latest News from Nick Kean

Drivve Image 9

Drivve Image 9 has just been released! It comes with lots of great new...

Written by: Nick Kean


Drivve Image v8

Premium scanning solution Drivve Image is now on version 8. Drivve Image v8 h...

Written by: Nick Kean



Selectec have proved to be a great company to partner with. I have worked with Selectec for 7 years now, and am always impressed with their professionalism and eagerness to help. Both with sales and technical support, Selectec have always strived to give any information that I need, and gone above and beyond when I’ve needed a little extra help. I can’t recommend them highly enough.

Jon Farquharson Abbey Business Group
Back to Top ↑