That's very simple.
jscript code:
return BrowseDialog.FilePath;
pm = BrowseDialog.FilePath;
You are returning before setting the variable, that means you end the function right there. Everything else that comes afterwards won't be executed. So, this is very simple to fix: first set the pm variable, then return its value.
jscript code:
pm = BrowseDialog.FilePath;
return pm;
As for your second question: yes, have a look at
matty's reply to Browse For File featuring an implementation of GetOpenFileName which works both on XP and Vista. You'll probably want to change some things, like getting it out of the OnEvent_Initialize function and such.
If you're having trouble with this, we'll help you with that, but it's better to experiment with it a bit first and try things yourself - it really is the best way to learn programming.