routine MOVE.TO given ICON, X, Y, SPEED, CONTROL.COMPRESSION
''
'' AUTHOR: Steve Bailey
'' CREATED: 8-7-90
'' DESCRIPTION:
''     This routine moves an icon from one location to another
''

define ICON as a pointer variable
define X,Y as real variables
define SPEED as a real variable
define CONTROL.COMPRESSION as an integer variable
define DX,DY as real variables
define DISTANCE as a real variable
define NUM.MOVING as an integer saved variable

let DX = X - LOCATION.X(ICON)
let DY = Y - LOCATION.Y(ICON)

'' move icon to station
if DX ne 0 or DY ne 0
    if CONTROL.COMPRESSION ne 0 and COMPRESS.TIME ne 0
        add 1 to NUM.MOVING
        let TIMESCALE.V = TIMESCALE
    always

    let DISTANCE = SQRT.F(DX*DX + DY*DY)
    let VELOCITY.A(ICON) = VELOCITY.F(SPEED, ARCTAN.F(DY,DX))
    work DISTANCE / SPEED units
    let VELOCITY.A(ICON) = 0

    if CONTROL.COMPRESSION ne 0 and COMPRESS.TIME ne 0
        subtract 1 from NUM.MOVING
        if NUM.MOVING eq 0
            let TIMESCALE.V = 0
        always
    always
always

display ICON at (X, Y)

return
end
