1. Dir Problems

Hi all,

Two directory problems with exw:

1. If you try to run a euphoria/win program located in a directory whose
long filename (even even long pathname) has spaces, you get an error like this:

   Can't open C:\Euphoria\EarTest\dist\Source\Blog.exw

The actual filename of the program is this:

   C:\Euphoria\EarTest\dist\Source\Blog fog\test.exw

2. If you have a euphoria program bound to exw and the name of the
directory the program is in is too long (haven't got an exact figure, but
say over 50 characters long), you get this message:

---------------
Euphoria 2.1 Public Domain Edition for 32-bit Windows.
Copyright (c) Rapid Deployment Software 1999
Permission is freely granted to anyone to copy and
redistribute this Public Domain Edition of Euphoria.

file name to execute?
----------------

Cut the directory name down to normal size, and it starts working just fine.


On a possibly related note (and the reason I was messing around with such
obscure stuff), I discovered that if you are using MCISendString to (say)
play a wav file, it chokes and croaks in the most remarkable way if the
path to your wave file has a directory or filename with a space in it.

I discovered this because I was working on an install script for a Euphoria
program and by default it installs things in "c:\Program Files".  With that
space in the directory name, wave files that were playing quite beautifully
before, suddenly quit working altogether.

It turns out that MCI strings are space delimited and won't allow quotation
marks (!).  MCI strings commonly have a pathname as part of them, and we
all know that pathnames under Win95+ commonly have spaces in them. So how
do you deal with the problem?

The solution (the only reasonable one I can figure, anyway) is to send the
"shortpathname" as the MCI string, instead of sending the "longpathname".
Luckily there is a windows procedure to get the short pathname for you if
you have the long pathname.

Here is some code to get the short pathname. It might (?) be nice to have
something like this somewhere in Euphoria, or in include files. Maybe even
in machine.e or somewhere, as it seems closely related to current_dir and
other such functions.

You use the code below something like this:

    shortpath=GetShortPathName(longpath)

----------------------------------------------------------------
--OK, it's not beautiful, but it works (so far, anyway . . . )

constant  getShortPathName= link_c_func(kernel32, "GetShortPathNameA",
{C_POINTER, C_POINTER, C_INT}, C_INT)


global function GetShortPathName(sequence longpath)
  sequence shortpath
  integer result, len
  atom lp, sp

  len=200
  lp=allocate_string(longpath)


    shortpath=repeat(0,len)
    sp=allocate_string(shortpath)
    result=c_func(getShortPathName,
       {lp,  -- points to a null-terminated path string
        sp,  --points to a buffer to receive the null-terminated short form
of the path
        len}) -- specifies the size of the buffer pointed to by sp

    if result > len then --if len wasn't long enough, then result is
                         --now the correct length
         len = result
         free (sp)
         shortpath=repeat(0,len)
         sp=allocate_string(shortpath)

         result=c_func(getShortPathName,
                   {lp,
                    sp,
                    len})
    end if

    shortpath = peek ({sp, result})
    free (sp)
    len=result
    free (lp)

  if result > 0 then return shortpath
  else return longpath end if           --if result = 0 then we had an error

end function

----------------------------------------------------------------


++++++++++++++++++++ Brent Hugh / bhugh at cstp.umkc.edu ++++++++++++++++++++
++++++++ University of Missouri-Kansas City, Conservatory of Music +++++++
++ Sheet Music/Recordings: http://www.sunflower.org/~bhugh/pathetic.spm ++
+ Internet Piano Concert:  http://cctr.umkc.edu/userx/bhugh/recital.html +
++++++++++ Classical Piano MP3s http://www.mp3.com/brent_d_hugh ++++++++++

new topic     » topic index » view message » categorize

2. Re: Dir Problems

Why don't you use the Euphoria dir95.ew library, or whatever that's called.
It has all that stuff built in (long dir names, short dir names, files,
etc.), instead of messing w/the DLLs?

Making the pool deeper...
Mike Hurley

________________________________________________________
NetZero - We believe in a FREE Internet.  Shouldn't you?
Get your FREE Internet Access and Email at
http://www.netzero.net/download/index.html

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

3. Re: Dir Problems

Brent Hugh writes:
> 1. If you try to run a euphoria/win program located in a directory
> whose long filename (even even long pathname) has spaces,
> you get an error like this:

>  Can't open C:\Euphoria\EarTest\dist\Source\Blog.exw

> The actual filename of the program is this:

>   C:\Euphoria\EarTest\dist\Source\Blog fog\test.exw

It would appear that you have forgotten to put double
quotes around your path name, so exw is interpreting the line
as a file path followed by an extra argument: fog\test.exw.
Remember that you need double quotes whenever you
provide a path that contains blanks. This is true for exw
and for other DOS and Windows commands. i.e. you
should have typed:

  exw "C:\Euphoria\EarTest\dist\Source\Blog fog\test.exw"

(In a Euphoria open statement,  extra quotes should
*not* be used.)

I think some of your other concerns might also be related to this.

Regards,
     Rob Craig
     Rapid Deployment Software
     http://www.RapidEuphoria.com

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

4. Re: Dir Problems

At 05:36 PM 8/21/99 -0400, you wrote:
>Brent Hugh writes:
>> 1. If you try to run a euphoria/win program located in a directory
>> whose long filename (even even long pathname) has spaces,
>> you get an error like this:
>
>>  Can't open C:\Euphoria\EarTest\dist\Source\Blog.exw
>
>> The actual filename of the program is this:
>
>>   C:\Euphoria\EarTest\dist\Source\Blog fog\test.exw
>
>It would appear that you have forgotten to put double
>quotes around your path name, so exw is interpreting the line
>as a file path followed by an extra argument: fog\test.exw.
>Remember that you need double quotes whenever you
>provide a path that contains blanks. This is true for exw
>and for other DOS and Windows commands. i.e. you
>should have typed:
>
>  exw "C:\Euphoria\EarTest\dist\Source\Blog fog\test.exw"

I think you're quite right--but I was just double-clicking "test.exw" from
Windows Explorer, so I naturally assumed Explorer would handle all this the
right way internally.

Looking in Explorer/view/options/file types I see that you have to have the
"open" for .exw files set to something like

  c:\euphoria\bin\exw.exe "%1"

On my system, it wasn't--and there was the cause of the problem.

As for problem with MCIString, it is indeed related to the double quote
issue. The trouble is that according to MCIstr.hlp

>Strings--String data types are delimited by leading and trailing white space
>and quotation marks ("). MCI removes single quotation marks from a string.
>If you want to put a quotation mark in a string, use a set of two quotation
>marks where you want to embed your quotation mark. If you want to use an
>empty string, use two quotation marks to delimit the empty string.

That sounds simple enough, except that if you actually put the "two
quotation marks" in an mcistring anywhere, it chokes with an astounding
variety of messages, depending on the exact situation.  The same goes for
normal quotation marks, and every other combination I could dream up, that
might remotely have a chance of working.

All of this is more difficult because the MCIString documentation is
extraordinarily sketchy and they don't feel the need to give examples.

Thanks again for your help!

--Brent






++++++++++++++++++++ Brent Hugh / bhugh at cstp.umkc.edu ++++++++++++++++++++
++++++++ University of Missouri-Kansas City, Conservatory of Music +++++++
++ Sheet Music/Recordings: http://www.sunflower.org/~bhugh/pathetic.spm ++
+ Internet Piano Concert:  http://cctr.umkc.edu/userx/bhugh/recital.html +
++++++++++ Classical Piano MP3s http://www.mp3.com/brent_d_hugh ++++++++++

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

5. Re: Dir Problems

On Sat, 21 Aug 1999 17:38:33 -0500, Brent Hugh <bhugh at CSTP.UMKC.EDU> wrote:

>That sounds simple enough, except that if you actually put the "two
>quotation marks" in an mcistring anywhere, it chokes with an astounding
>variety of messages, depending on the exact situation.  The same goes for
>normal quotation marks, and every other combination I could dream up, that
>might remotely have a chance of working.


Brent
     Did you try the "C" escape character backslash followed by the qoute
     that you want ignored like this:     \"
Bernie

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

Search



Quick Links

User menu

Not signed in.

Misc Menu