1. haha very funny

sequence dirs
    dirs = dir(FileSpec)
    for i = 1 to length(dirs) do

dirs will actually contain file or directory info if there are any files or
directories

This from the Euphoria docs:

d = dir(current_dir()) -- this says right up front dir( ) returns a sequence
doesnt it!

-- d might have:
  {
    {".",    "d",     0  1994, 1, 18,  9, 30, 02},
    {"..",   "d",     0  1994, 1, 18,  9, 20, 14},
    {"fred", "ra", 2350, 1994, 1, 22, 17, 22, 40},
    {"sub",  "d" ,    0, 1993, 9, 20,  8, 50, 12}
  }

OK, very well then, but when it doesnt contain info the return value is -1 which
gives us a type_check error...

OK then, we name dirs as an object and because we look for a length to dirs
next we get this error message > length of an atom not defined.....huh

this from the Euphoria Docs
If there is no file or directory with this name then -1 is returned

OK, if we keep the dir defined as an object and run a test to make sure dirs is
not -1 like
this:

if dir(FileSpec) != -1 then we get  true/false condition must be an ATOM

and damn I could list several other error messages and code but you all get the
point now.

We are so restricted it's not funny...
I'll go to bed now.....later yall.

Euman
euman at bellsouth.net

new topic     » topic index » view message » categorize

2. Re: haha very funny

euman at bellsouth.net wrote:

> d = dir(current_dir()) -- this says right up front dir( ) returns a
sequence doesnt it!

Well, not really. It returns a sequence _if_ the routine succeeds. If
not, it returns an integer. So you can write your test:

   object d
   d = dir( ... )
   if integer( d ) then
      ... failure code
   else
      ... success code
   end if

or use 'not sequence(d)' if you prefer. It's idiomatic to Euphoria, and
shows up in a number of places. For example:

   while 1 do
      result = gets( handle )
      if integer( handle ) then
         exit
      end if
   end while

I'll grant that it's a bit odd, but it's more or less consistant.

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu