How to make error handling for the end user ?

Author Message
Hackoo

  • Total Posts : 104
  • Scores: 4
  • Reward points : 0
  • Joined: 6/25/2010
  • Status: offline
How to make error handling for the end user ? Sunday, December 11, 2011 5:00 PM (permalink)
0
Hi!
I have this HTA to compare two files, but i just want to improve it more and more. So my question is : How to make error handling for the end user when it fails or fogots to choose the file N°1 or File N°2 or both ?
i.e showing a msgbox to warn him that has missed to choose the file for example and exit the function or something else
Thank you in advance for your help !
<html>
 <head>
 <title>File2Compare</title>
 <HTA:APPLICATION
 APPLICATIONNAME="File2Compare"
 ID="File2Compare"
 BORDER="dialog"
 INNERBORDER="no"
 MAXIMIZEBUTTON="no"
 SCROLL="no"
 VERSION="1.0"/>
 <style type="text/css">
 /* Theme created by subBlue design for phpBB, http://www.subBlue.com avec queleques modification apporté par Hackoo
 ©2001, 2005 phpBB Group, http://www.phpbb.com/    */
 input,button
 {
 border:1px solid #FF6A22;
 background-color:lightgreen;
 font-family:Comic sans MS;
 font-size:12px;
 color:#804040;
 font-weight:bold; 
 }
 textarea{background-color:none;}
 
 body { 
 overflow:auto;
 position:relative;
 top:5px;
 left:5px;
 scrollbar-face-color: #DEE3E7;
 scrollbar-highlight-color: #FFFFFF;
 scrollbar-shadow-color: #DEE3E7;
 scrollbar-3dlight-color: #D1D7DC;
 scrollbar-arrow-color:  #006699;
 scrollbar-track-color: #EFEFEF;
 scrollbar-darkshadow-color: #98AAB1; 
 background-color:lightblue;
 margin-top:4px;
 
 
 color:none;
 filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#FF7DFF', EndColorStr='lightgreen'); 
 }
 
 button    {    border:1px solid #FF6A22;
 background-color:#FFFF00;
 font-family:Verdana;
 font-size:9px;
 height:14px;
 font-weight:bold; 
 cursor:hand;    }
 
 
 div.forumline {margin-left:8px; background-color: lightblue; border: 2px #006699 solid; float:left; 
 height:480px; width:250px; overflow:scroll;  }
 div.form {float:left;font-family:Comic sans MS;} 
 div.toolbar {width:98%; font-family:Comic sans MS;}
 
 th,td,p { font-family: Verdana, Arial, Helvetica, sans-serif }
 hr    { height: 0px; border: solid #D1D7DC 0px; border-top-width: 1px;}
 .gen { font-size : 14px; }
 .genmed { font-size : 11px; }
 .gensmall { font-size : 10px; }
 .gen,.genmed,.gensmall { color : #000000; }
 a.gen,a.genmed,a.gensmall { color: #006699; text-decoration: none; }
 a.gen:hover,a.genmed:hover,a.gensmall:hover    { color: #DD6900; text-decoration: underline; }
 input.button {  background-color : #EFEFEF;
 color : #000000; cursor:hand;
 font-size: 11px; font-family: Verdana, Arial, Helvetica, sans-serif; }
 input.longbt {  background-color : #EFEFEF;
 color : #000000;
 font-size: 11px; font-family: Verdana, Arial, Helvetica, sans-serif; width:100px}
 .code { font-family: Courier, 'Courier New', sans-serif; font-size: 11px; color: #006600;
 background-color: #FAFAFA; border: #D1D7DC; border-style: solid;
 border-left-width: 1px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px }
 .quote {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #444444; line-height: 125%;
 background-color: #FAFAFA; border: #D1D7DC; border-style: solid;
 border-left-width: 1px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px }
 .err{color: white; background-color: red; font-family: Verdana, Arial, Helvetica, sans-serif }
 #FolderPath{color:#FF0000}
 </style>
 </head>
 <script language="VBScript">
 Function File2Compare(File1,File2)
 Const ForReading = 1, ForWriting = 2 
 Dim objFSO,objSourceFile,objSourceFile2 
 File1=File1.value
 File2=File2.value
 
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 Set objSourceFile = objFSO.OpenTextFile(File1, ForReading) ' original File
 Set objSourceFile2 = objFSO.OpenTextFile(File2, ForReading) 'Modified File
 
 vrNumLigne = 0
 Do Until objSourceFile.AtEndOfStream Or objSourceFile2.AtEndOfStream
 vrNumLigne = vrNumLigne + 1
 vrLigne = objSourceFile.ReadLine
 vrLigne2 = objSourceFile2.ReadLine
 vrComprLign = StrComp(vrLigne, vrLigne2, 1)
 If vrComprLign = 1 Or vrComprLign = -1 Or IsNull(vrComprLign) Then
 vrNul = "The file has not been changed"
 vrLignDif = vrLignDif & vrNumLigne & ": " & vrLigne &  vbCrLf & vrNumLigne & ": " & vrLigne2 & vbCrLf &  vbCrLf
 End If
 Loop
 objSourceFile.Close
 objSourceFile2.Close
 If IsEmpty(vrNul) Then
 MsgBox "The file has not been changed",64,Title
 Else
 MsgBox vrLignDif,64,Title
 Dim fso, f 
 Set fso = CreateObject("Scripting.FileSystemObject") 
 Set f = fso.OpenTextFile("comparaison.txt", ForWriting,true) 
 f.writeline(vrLignDif)
 
 txtBody.value = vrLignDif
 f.close
 End If
 End Function
 Sub Window_OnLoad
 'This method will be called when the application loads
 'Add your code here
 End Sub
 Sub OnClickButtonOK()
 'This method will be called when OK is clicked
 'Add your code here
 window.Close
 End Sub
 
 Sub OnClickButtonCancel()
 'This method will be called when Cancel is clicked
 'Add your code here
 window.Close
 End Sub
 
 </script>
 
 <center>
 <label>Fichier N°1:</label><input type="file" name="file1" id="file1" /><br>
 <label>Fichier N°2:</label><input type="file" name="file2" id="file2" /><br>
 <label>Résultat de la Comparaison:</label><br/>
 <textarea id="txtBody" rows="23" cols="80"></textarea><br><br>
 <input type="button" style="width: 140px" name="OK" id="OK"  value="Comparer les Fichiers" onclick="File2Compare File1,File2">
 <input type="button" style="width: 100px" name="Cancel" id="Cancel" value="Sortir" onclick="OnClickButtonCancel">
 </td></tr>
 </table>
 </table>
 </body>
 </html>

 
#1
    59cobalt

    • Total Posts : 973
    • Scores: 91
    • Reward points : 0
    • Joined: 7/17/2011
    • Status: online
    Re:How to make error handling for the end user ? Monday, December 12, 2011 7:08 AM (permalink)
    0
    I'd say the common way to handle bad/missing user input is to add a red marker (*) left or right of the input box along with some explanatory text (in red as well).
     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9