1)In my code the active screen displays the screen for the next lines not at the lines on which the cursor is kept.
So could anyone help me how to make the display of the screen for that particular line on which the cursor is placed.
2)Is there any shotcut keys to find the loop start and end i.e to which FOR the particular NEXT belongs.
The script runs exactly for some lines where the active screen shows the exact screen when cursor is placed in the particular line and for the rest of the lines it hangs.
It seems the script couldn't able to recognise the current line.
It could be that you added/deleted a few lines in your script after recording. QTP has some hidden code in the scripts to mark which active screen belongs to which line of code (open the script.mts using an ordinary text editor like NotePad and search for @@ or _;_ then you'll know what I mean). These hidden codes were created by QTP during recording. If you manually add / delete lines of code after recording, it may result in disposition of the active screen.
Note that the second halves of first and third line have such strings that start with @@ (double @) and end with _;_
If you use QTP to open this test, you won't see this trailing parts. You'll only see the first half of the line. Only when you open this script.mts file using a plain test edit (NotePad or TextPad...) then you'll see them.
These "hidden" codes associate the active screen with a certain step of operation (in the script this means a line of code).
When you manually added / deleted lines of scripts, such association could get "off alignment" so the active screens show up at wrong time.
This may or may not be the explanation of the issue you are seeing. If it is the thing that brings to you the trouble, update run may help. When you do update run, make sure the "Update Active Screen images and values" under "Update Options" tab is checked.