Array Helper

For a project i am working on i wanted to work with Arrays. In Lectora. But that aint anywhere available within the normal toolset, so at some point i decided to make my own ArrayHelper with which i could create an array of texts, numbers or page-elements inside Lectora and then use Javascript to either push or pull elements from the array and do something with them inside Lectora.

So how does that work ?

When you check either the preview or the .awt you see a textfield on the top with a series of numbers delimited with a comma. Thats my first sample array. Just an textfield. When you click the button ‘get arrayEntry’ a Javascript is called that gets the data from the textfield and splits it on the comma’s thus creating an array of it. Then it gets the proper value for the value you put into the inputfield next to the button. Arrays always start at 0.

Extra nice trick inhere is the formatting i do after the output textfield gets its new data. Normally these kind of textfields loose formatting due to the new data Lectora pushes in it. Well by using Javascript you can force a format upon a textfield after that.

The second part downbelow shows exactly the same, but now with page-elements. You see a textfield with a start and an end, and then randomly in it the pngs you see downbelow.

If you choose to act on a specific item of the array…changing the 2nd inputfield to any number of the array… the script on the button will check if any image on the page…yes any image… is called like the name in the array. If thats the case it hides it. Just add a new image to the .awt… with any name you have…. add it in the textfield too… test.jpg or whatever it is called… and try…and you see it works perfect even with that image of your Grandma’s knickers 😉

Math

Preview image

Tags:

Your email address will not be published. Required fields are marked *