I haven't worked with MDX for quite a while but if I remember correctly you can use $did().sel to return the line number, then you can just use an if statement to perform the tasks you want assigned to that line.
If $did().sel doesn't work, try $did().seltext. I know it's one of the two, or it could be both.