The entire block of code concerns moving the 'attack' handle on the envelope.
if chnget:k("MOUSE_DOWN_LEFT")==1 && kY< iGtHeight+iGtYPos then
The above line asks: "is the mouse button pressed and is the mouse Y position over the 'A' handle?". (iGtHeigth is the height of the envelope panel. iGtYPos is the position of the envelope panel within the main panel.) If both parts of the above question are true, the next line of code is executed.
if kX > -2 && kX < kDPos && kDecDragging!=1 && kSusDragging!=1 && kRelDragging!=1 then
This line asks: "is the mouse X position greater than -2 (i.e. over the main panel), and less than the position of the 'D'/decay handle, and that none of the other handles 'D', 'S' and 'R', are currently being dragged. (These three variables, kDecDragging etc, are 'flags' that are used to indicate whether a particular handle is being dragged.
kAPos = kX - iGtXPos
This line sets the variable for the X position of the 'A' handle to the X position of the mouse.
SMessage sprintfk "pos(%f, 5)", kAPos
This creates a string variable message that will be send to the 'A' handle. This message will give details about a new position for the widget.
chnset SMessage, "attIdent"
This sends the message to the widget. The widget is moved to its new location.
kAttDragging = 1
This is a so-called 'flag' which is used to indicate that the 'A' handle is being moved. It is used to ensure that the other handles, 'D', 'S' and 'R', can't be moved simultaneosly.