This illustrates how you can use the DynamicCoordinates command to create a point which 'snaps' to grid positions, and then use that point to create other objects (in this case, a draggable square grid).
GeoGebra script techniques used -
* The DynamicCoordinates command to create the snapped point
* The Sequence and Segment commands to create horizontal and vertical lists of segments, depending on the x and y position of the snapped point.