Title: Re: How to detect error in "Set Directory"

I'm using your work-around, but I'd sure like something better.  That work-around has two major problems:
1)  The error message I usually get is "Can't open directory."  This is a legal directory name!  I can catch some but not all errors this way.

2)  This makes a lot of assumptions about what MetaCard's doing, and what I'm doing.  Change the statement to 'get commonDir() & "/" & userName();set the directory to it;answer the result'.  Now, on success, the result will be userName(), not the value of 'it'.  So I need to know a lot of history (and the order in which MetaCard executes the two functions) to determine what's an error.

At a bare minimum this behavior needs to be documented.  I spent a lot of time fighting this because:
1)  'set the directory to "my simple command line example" works differently from 'set the directory to myRealFunctionWhichIsNotVisibleToTheCommandLine()"' so I couldn't see what was going on.

2)  'Answer the result' clears the result (always, it can't return a value or an error), which made me think that 'set the directory' was clearing the result from the previous call to 'set the directory'

3)  I can't find any discussion of what does and does not clear the result.  (i.e. answer always set it to empty, set the directory only sets it on error, get/put never changes it.)

>Subject: Re: How to detect error in "Set Directory"
>Date: Wed, 07 Jun 2000 06:02:11 -0700
>
>On 7/6/00 2:31 am, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>> How do I detect an error in a "Set Directory" statement?
>>
>> It appears that 'set the directory to "My Dir"; answer the result' will return
>> an empty string on success, an error message on failure.  This behavior makes
>> sense.
>>
>> But 'set the directory to myFunction(); answer the result' appears to return
>> the result of myFunction on success, and an error message on failure.  I found
>> this unacceptable because myFunction may return something that looks like an
>> error.
>>
>> I'm assuming that 'the result' was getting confused by the function call.  So
>> I tried 'get myFunction(); set the directory to it; answer the result'.  This
>> form returns the value of 'it' on success, an error message on failure.  So I
>> have the same problem as with the function call.
>
>Right: the function itself will set the result, and if setting the directory
>works the result will not be altered.  Only on failure of setting the
>directory will the result be changed to indicate failure.  Its borderline
>that this might be considered a bug, but anyhow its easy to work around:
>
>get myFunction()
>put the result into tCheckResult
>set the directory to it
>if the result is not tCheckResult then
>  --we have an error
>end if
>
>Regards,
>
>Kevin
>
>Kevin Miller <[EMAIL PROTECTED]> <http://www.xworlds.com/>
>Cross Worlds Computing, MetaCard Distributors, Custom Development.
>Tel: +44 (0)131 672 2909.  Fax: +44 (0)1639 830 707.

Reply via email to