Ah Ok, I understand now !
Thanks a lot for your help.
Arnaud
"Edengundam" wrote:
> <PowerShell In Action> metioned this case, I paste the Author note here:
>
> The example here uses 1/$null. The reason for doing this instead of simply
> 1/0 is because the PowerShell interpreter does something called constant
> expression folding. It looks at expressions that contain only constant
> values. When it sees one, it evaluates that expression once at compile time
> so it doesn¡¯t have to waste time doing it again at runtime. This means that
> impossible expressions, such as division by zero, are caught and treated as
> parsing errors. Parsing errors can¡¯t be caught and don¡¯t get logged when
> they¡¯re entered interactively, so they don¡¯t make for a good example. (If
> one
> script calls another script and that script has one of these errors, the
> calling
> script can catch it, but the script being parsed cannot.)
>
> "A. Petitjean" <APetitjean@discussions.microsoft.com>
> news:E32C470A-9D56-498C-837B-F15C2A06147B@microsoft.com...
> > When I try this
> > trap { "Got it : division by zero !" } 1/$null; "next"
> >
> > The trap is working successfully :
> > Got it : division by zero !
> > Tentative de division par z¨¦ro.
> > Au niveau de ligne : 1 Caract¨¨re : 44
> > + trap { "Got it : division by zero !" } 1/$ <<<< null; "next"
> >
> > But when I try this (who's the same thing in theory) :
> > trap { "Got it : division by zero !" } 1/0; "next"
> >
> > I got :
> > Tentative de division par z¨¦ro.
> > Au niveau de ligne : 1 Caract¨¨re : 44
> > + trap { "Got it : division by zero !" } 1/0 <<<< ; "next"
> >
> > And my trap is not working !!!
> >
> > What's wrong !? I have a big headhache with that problem ! Please help me
> !
> >
> > Arnaud Petitjean
> > http://www.powershell-scripting.com
> > The PowerShell's French Community
>
>
>