Get Object Location

Returns the X and Y locations (i.e. the distance from the left and the top of the screen) of a nominated Simulation Object.

While these can be found by hovering over the building blocks in the bottom-left corner of the application, the command is most useful in a simulation where Visual Logic is used to copy Objects. In these cases, it is used to obtain the position of the original Object so that it can be used for positioning the copied Object.

Parameters
* Simulation Object: The Object’s position to be found out.

  • X: a local variable (type number) which will get the horizontal location of the Object
  • Y: a local variable (type number which will get the vertical location of the Object

Comments

The X and Y locations parameters should be declared as Global or Local variables, for them to be able to store the Object’s locations.

Remember that each Object’s position from the right to the left can also be found on the Input Summary.

Annotated Examples

In the example below, the user defines which Activity’s location to inspect, by adjusting the lcl_ObjectNumber Local variable. The locations are stored in lcl_X and lcl_Y, for X and Y locations respectively, and they are then communicated to the user with a message displayed on screen.

This command can also be used in conjunction with the Get Current Object command, which returns the Object the current piece of Visual Logic is triggered. This example finds the Activity where the Proc_ObjectsLocation procedure was triggered and returns its location with a message displayed on screen.

You can find a simulation example of this here: getobjectlocation.s8

See Also