- Create another new Script Include, available at System Definition > Script Includes:
function square (x) {
return x * x;
}
Notice how square is written with an initial lowercase letter, since it is a single function. SimpleMath started with an upper case letter, since it is a class.
- You can then run this in Background Scripts in the x_hotel scope very easily:
gs.info(x_hotel.square(10));
It is much better to group similar functions together in a single utility class. This will also give them a namespace, which means it is less likely there will be collisions or variables with the same name.