diff options
author | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2011-07-25 13:33:43 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graeme@mastermaths.co.za> | 2011-07-25 13:33:43 +0200 |
commit | 575d3f582674f5135cc084fb0f27250700f8a935 (patch) | |
tree | b09b0f250e344882e28474d650e7a188bdac2237 /docview | |
parent | ca9a8de1df0690a1ee86ce39c3e6f3bc7d381c8b (diff) | |
download | fpGUI-575d3f582674f5135cc084fb0f27250700f8a935.tar.xz |
docview: -n parameter validation
We now gracefully handle invalid -n parameter values, and notify the enduser
of such a problem - instead of just crashing out.
Diffstat (limited to 'docview')
-rw-r--r-- | docview/src/frm_main.pas | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/docview/src/frm_main.pas b/docview/src/frm_main.pas index e3617bd3..3c0590b5 100644 --- a/docview/src/frm_main.pas +++ b/docview/src/frm_main.pas @@ -3338,6 +3338,7 @@ procedure TMainForm.ProcessCommandLineParams; var showtopic: boolean; t: TTopic; + n: integer; begin if ParamCount > 0 then begin @@ -3368,8 +3369,17 @@ begin else if gCommandLineParams.IsParam('n') then begin { Display topic with numeric topic id } - t := FindTopicByResourceID(StrToInt(gCommandLineParams.GetParam('n'))); - DisplayTopic(t); + try + n := StrToInt(gCommandLineParams.GetParam('n')); + t := FindTopicByResourceID(n); + DisplayTopic(t); + except + on EConvertError do + begin + TfpgMessageDialog.Critical('Invalid Parameter Value', + '<' + gCommandLineParams.GetParam('n') + '> is not an number.'); + end; + end; end else if gCommandLineParams.IsParam('s') then begin |