Postscript... I realize now that openDlg() might be some core javascript method that I'm not familiar with, although I can't find much about it. In any case, see what filename equals afterwards. If it equals nothing, that is your problem. Consider using the FM ExtendScript method instead:
ChooseFile(title, directory, stuffVal, mode)
Russ