Re: [fpc-pascal] mciSendString with long file names

2022-09-22 Thread Sven Barth via fpc-pascal
Dennis Lee Bieber via fpc-pascal  schrieb
am Fr., 23. Sep. 2022, 04:10:

>If FP is attempting to translate \ into some escape code, you
> might try doubling the backslashes... C:\\Program Files\\My Program\\...
> (I'm presuming "Progam" is a typo.
>

FPC has no need for that as "\" isn't used as an escape character, unlike
for C.

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] mciSendString with long file names

2022-09-22 Thread Travis Siegel via fpc-pascal
A solution I started using, because the mci commands (for some reason) 
don't handle all mp3 files I have, was to use a dll called fmod.dll.  It 
handles several formats, not just mp3, and it can be started on another 
thread, then ignored.  I've used it to build a much better mp3 player 
than I was able to make using the mci commands, since now I can handle 
other formats as well, which helps since interestingly enough, I'm still 
finding files in other formats burried in my collections, and so far, 
the fmod program handles them all nicely


It can't be used in a commercial application, but it doesn't sound like 
yours is, so you should be ok.



On 9/22/2022 4:22 PM, James Richters wrote:

Sorry for the confusion.   Let me clarify:

The freepasal program is always run on a Windows system,  mciSendString is a 
Windows function.  I've seen solutions for this problem that use the NTFS 8.3 
Short file name... Which I thought would work, but, for my application it won't 
work because the file is being loaded off a network drive, and the SERVER for 
the file is a Linux server.. but even though it's a Linux server, the path on 
my windows system is still uses backslashes not forward slashes... It's a 
FreeNAS server with Windows file sharing.  Anyway the point was that only 
windows NTFS formatted drives have the short file name.. so that solution won't 
work at all.  I want the program to be able to play the sound file no matter 
where the file is stored on the network or on a flash drive or a ramdrive.. 
etc,  and not have a requirement that it is an NTFS drive.

So it has to work with windows paths.  Almost all windows applications just put 
it in quotes, but mciSendString does not play nice.  I think it was invented 
during 8.3 limitations and it was only hacked to kind of work with long file 
names.. not really work properly.  The Alias method does work, but it's not so 
convenient for Asynchronous mode because it leaves the file open.. if you close 
it before it finishes playing, it stops and if you wait for it to finish and 
then close it.. well, that's just not asynchronous.

James

-Original Message-
From: fpc-pascal  On Behalf Of Travis 
Siegel via fpc-pascal
Sent: Thursday, September 22, 2022 3:27 PM
To: ja...@productionautomation.net; FPC-Pascal users discussions 

Cc: Travis Siegel ; James Richters 

Subject: Re: [fpc-pascal] mciSendString with long file names

That's on windows, you said the program was running on linux.  In that case, 
backslashes will escape the spaces, allowing the path to be found properly.

Windows paths are different, as mentioned before, they can be escaped too, but 
the character is different.

On 9/22/2022 2:57 PM, James Richters via fpc-pascal wrote:

Won’t backslashes before each space be defining a subdirectory?

If my path looks like:
C:\Program Files\My Program\Some File.MP3 I don't see how changing it
to:
C:\Program\ Files\My\ Progam\Some\ File.MP3 can possibly work.. it's just 
butchering the path.

James


From: fpc-pascal  On Behalf
Of Travis Siegel via fpc-pascal
Sent: Wednesday, September 21, 2022 4:15 PM
To: FPC-Pascal users discussions 
Cc: Travis Siegel ; Jean SUZINEAU

Subject: Re: [fpc-pascal] mciSendString with long file names

Adding a backslash (\) before each space should do the job nicely.  I have had similar 
issues on linux and windows with some commands, and adding the escape characters to the 
filename almost always fixes the problem.  The only time it didn't, was when the filename 
started with a dash "-" character.  Otherwise, the backslash always works for 
me.

On 9/20/2022 4:16 PM, Jean SUZINEAU via fpc-pascal wrote:
May be by escaping the spaces with ^ ?
Something like:  MyFileName:= StringReplace(MyFileName, ' ', '^ ',
[rfReplaceAll]); ^ is the escape char for cmd.exe but may be it is active in 
this context too ?
Le 20/09/2022 à 18:31, James Richters via fpc-pascal a écrit :
I just tried it that way:
Var
pcmd: String;
MyFileName: String;
   
pcmd:='play "'+MyFileName+'"'+#0;

mciSendString(@pcmd[1],Nil,0,0);
   




___
fpc-pascal maillist  -  mailto:fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] mciSendString with long file names

2022-09-22 Thread James Richters via fpc-pascal
Sorry for the confusion.   Let me clarify:

The freepasal program is always run on a Windows system,  mciSendString is a 
Windows function.  I've seen solutions for this problem that use the NTFS 8.3 
Short file name... Which I thought would work, but, for my application it won't 
work because the file is being loaded off a network drive, and the SERVER for 
the file is a Linux server.. but even though it's a Linux server, the path on 
my windows system is still uses backslashes not forward slashes... It's a 
FreeNAS server with Windows file sharing.  Anyway the point was that only 
windows NTFS formatted drives have the short file name.. so that solution won't 
work at all.  I want the program to be able to play the sound file no matter 
where the file is stored on the network or on a flash drive or a ramdrive.. 
etc,  and not have a requirement that it is an NTFS drive.

So it has to work with windows paths.  Almost all windows applications just put 
it in quotes, but mciSendString does not play nice.  I think it was invented 
during 8.3 limitations and it was only hacked to kind of work with long file 
names.. not really work properly.  The Alias method does work, but it's not so 
convenient for Asynchronous mode because it leaves the file open.. if you close 
it before it finishes playing, it stops and if you wait for it to finish and 
then close it.. well, that's just not asynchronous.

James

-Original Message-
From: fpc-pascal  On Behalf Of Travis 
Siegel via fpc-pascal
Sent: Thursday, September 22, 2022 3:27 PM
To: ja...@productionautomation.net; FPC-Pascal users discussions 

Cc: Travis Siegel ; James Richters 

Subject: Re: [fpc-pascal] mciSendString with long file names

That's on windows, you said the program was running on linux.  In that case, 
backslashes will escape the spaces, allowing the path to be found properly.

Windows paths are different, as mentioned before, they can be escaped too, but 
the character is different.

On 9/22/2022 2:57 PM, James Richters via fpc-pascal wrote:
> Won’t backslashes before each space be defining a subdirectory?
>
> If my path looks like:
> C:\Program Files\My Program\Some File.MP3 I don't see how changing it 
> to:
> C:\Program\ Files\My\ Progam\Some\ File.MP3 can possibly work.. it's just 
> butchering the path.
>
> James
>
>
> From: fpc-pascal  On Behalf 
> Of Travis Siegel via fpc-pascal
> Sent: Wednesday, September 21, 2022 4:15 PM
> To: FPC-Pascal users discussions 
> Cc: Travis Siegel ; Jean SUZINEAU 
> 
> Subject: Re: [fpc-pascal] mciSendString with long file names
>
> Adding a backslash (\) before each space should do the job nicely.  I have 
> had similar issues on linux and windows with some commands, and adding the 
> escape characters to the filename almost always fixes the problem.  The only 
> time it didn't, was when the filename started with a dash "-" character.  
> Otherwise, the backslash always works for me.
>
> On 9/20/2022 4:16 PM, Jean SUZINEAU via fpc-pascal wrote:
> May be by escaping the spaces with ^ ?
> Something like:  MyFileName:= StringReplace(MyFileName, ' ', '^ ', 
> [rfReplaceAll]); ^ is the escape char for cmd.exe but may be it is active in 
> this context too ?
> Le 20/09/2022 à 18:31, James Richters via fpc-pascal a écrit :
> I just tried it that way:
> Var
> pcmd: String;
> MyFileName: String;
>   
> pcmd:='play "'+MyFileName+'"'+#0;
> mciSendString(@pcmd[1],Nil,0,0);
>   
>
>
>
> ___
> fpc-pascal maillist  -  mailto:fpc-pascal@lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] mciSendString with long file names

2022-09-22 Thread Travis Siegel via fpc-pascal
That's on windows, you said the program was running on linux.  In that 
case, backslashes will escape the spaces, allowing the path to be found 
properly.


Windows paths are different, as mentioned before, they can be escaped 
too, but the character is different.


On 9/22/2022 2:57 PM, James Richters via fpc-pascal wrote:

Won’t backslashes before each space be defining a subdirectory?

If my path looks like:
C:\Program Files\My Program\Some File.MP3
I don't see how changing it to:
C:\Program\ Files\My\ Progam\Some\ File.MP3 can possibly work.. it's just 
butchering the path.

James


From: fpc-pascal  On Behalf Of Travis 
Siegel via fpc-pascal
Sent: Wednesday, September 21, 2022 4:15 PM
To: FPC-Pascal users discussions 
Cc: Travis Siegel ; Jean SUZINEAU 

Subject: Re: [fpc-pascal] mciSendString with long file names

Adding a backslash (\) before each space should do the job nicely.  I have had similar 
issues on linux and windows with some commands, and adding the escape characters to the 
filename almost always fixes the problem.  The only time it didn't, was when the filename 
started with a dash "-" character.  Otherwise, the backslash always works for 
me.

On 9/20/2022 4:16 PM, Jean SUZINEAU via fpc-pascal wrote:
May be by escaping the spaces with ^ ?
Something like:  MyFileName:= StringReplace(MyFileName, ' ', '^ ', 
[rfReplaceAll]);
^ is the escape char for cmd.exe but may be it is active in this context too ?
Le 20/09/2022 à 18:31, James Richters via fpc-pascal a écrit :
I just tried it that way:
Var
pcmd: String;
MyFileName: String;
  
pcmd:='play "'+MyFileName+'"'+#0;

mciSendString(@pcmd[1],Nil,0,0);
  




___
fpc-pascal maillist  -  mailto:fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] mciSendString with long file names

2022-09-22 Thread James Richters via fpc-pascal
Won’t backslashes before each space be defining a subdirectory?

If my path looks like:
C:\Program Files\My Program\Some File.MP3 
I don't see how changing it to:
C:\Program\ Files\My\ Progam\Some\ File.MP3 can possibly work.. it's just 
butchering the path.

James


From: fpc-pascal  On Behalf Of Travis 
Siegel via fpc-pascal
Sent: Wednesday, September 21, 2022 4:15 PM
To: FPC-Pascal users discussions 
Cc: Travis Siegel ; Jean SUZINEAU 

Subject: Re: [fpc-pascal] mciSendString with long file names

Adding a backslash (\) before each space should do the job nicely.  I have had 
similar issues on linux and windows with some commands, and adding the escape 
characters to the filename almost always fixes the problem.  The only time it 
didn't, was when the filename started with a dash "-" character.  Otherwise, 
the backslash always works for me.

On 9/20/2022 4:16 PM, Jean SUZINEAU via fpc-pascal wrote:
May be by escaping the spaces with ^ ?
Something like:  MyFileName:= StringReplace(MyFileName, ' ', '^ ', 
[rfReplaceAll]);
^ is the escape char for cmd.exe but may be it is active in this context too ?
Le 20/09/2022 à 18:31, James Richters via fpc-pascal a écrit :
I just tried it that way:
Var 
pcmd: String;
MyFileName: String;
 
pcmd:='play "'+MyFileName+'"'+#0;
mciSendString(@pcmd[1],Nil,0,0);
 



___
fpc-pascal maillist  -  mailto:fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal