Version française
Home     About     Download     Resources     Contact us    
Browse thread
small code problem
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Fabrice Le Fessant <fessant@p...>
Subject: Re: small code problem

 > This is a serious question (not an argumentative one).  How do I avoid 
 > Invalid_argument when I'm expecting the user to enter a filename on
 > the command-line?  Or are you just talking in general?

You can check the size of the array before reading it:

if Array.length Sys.argv < 2 then usage ();;
let filename = Sys.argv.(1)

will never raise an Invalid_argument exception.

- Fabrice

Homepage: http://pauillac.inria.fr/~lefessan