Sign in to follow this  
Followers 0
Alexxander

quotes in file path problem

8 posts in this topic

Hi all

i had found this function (it read an mp3 file length)

$FileName = '"C:\Users\Administrator\Desktop\1.mp3"'
mciSendString("Open " & $FileName & " alias MediaFile")
mciSendString("Set MediaFile time format milliseconds")
$answer = mciSendString("Status MediaFile length")
$answerfinl = Ceiling($answer / 1000)
mciSendString("Close MediaFile")
MsgBox(0,0,$answerfinl)
Func mciSendString($string)
   Local $ret
   $ret = DllCall("winmm.dll","int","mciSendString","str",$string,"str","","int",65534,"hwnd",0)
   If Not @error Then Return $ret[2]
EndFunc

it is working fine when i specify the path

out i want to input the pat using inputbox

i'll need variables

the problem is that i cant write the single quote and double quotes in the path and the unctio will not work until the path is surrounded by 2 single quotes and inside them 2 double quotes

i tried this but no luck 

$path1 = "C:\Users\Administrator\Desktop\"
$path2 = "1.mp3"
$FileName = ("'" & '"' & $path1 & $path2 & '"' & "'")

mciSendString("Open " & $FileName & " alias MediaFile")
mciSendString("Set MediaFile time format milliseconds")
$answer = mciSendString("Status MediaFile length")
$answerfinl = Ceiling($answer / 1000)
mciSendString("Close MediaFile")
MsgBox(0,0,$answerfinl)
Func mciSendString($string)
   Local $ret
   $ret = DllCall("winmm.dll","int","mciSendString","str",$string,"str","","int",65534,"hwnd",0)
   If Not @error Then Return $ret[2]
EndFunc

any ideas?


Share this post


Link to post
Share on other sites



Try this:

$FileName = '"' & $path1 & $path2 & '"'
1 person likes this

Share this post


Link to post
Share on other sites

 

Try this:

$FileName = '"' & $path1 & $path2 & '"'

 

woow it worked but can u explain how ? im confused i wasted a lot of time on this 


Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

woow it worked but can u explain how ? im confused i wasted a lot of time on this 

 

If you see, there is nothing special :)

For quote a string, we can use ' or "

If we want quote char " then we should use '

eg:

'"'

If we want quote char ' then we should use "

eg: "'"

edit: typo

Edited by michaelslamet
1 person likes this

Share this post


Link to post
Share on other sites

If you see, there is nothing special :)

For quote a string, we can use ' or "

If we want quote char " then we should use '

eg:

'"'

If we want quote char ' then we should use "

eg: "'"

edit: typo

 

so their is no need for srounding the path with single quotes and double quotes

'"C:UsersAdministratorDesktop1.mp3"'

you mean that only 2 double quotes is enough

"C:UsersAdministratorDesktop1.mp3"

thanks man you are awesome


Share this post


Link to post
Share on other sites

so their is no need for srounding the path with single quotes and double quotes

'"C:UsersAdministratorDesktop1.mp3"'

you mean that only 2 double quotes is enough

"C:UsersAdministratorDesktop1.mp3"

thanks man you are awesome

 

Yes, you're correct. Only 2 double quotes are enough, no need to surrounding the path with single quotes and double quotes.

No, I'm not awesome :P  This is basic and just you like, I learn a lot from many awesome people here :)

1 person likes this

Share this post


Link to post
Share on other sites

Yes, you're correct. Only 2 double quotes are enough, no need to surrounding the path with single quotes and double quotes.

No, I'm not awesome :P  This is basic and just you like, I learn a lot from many awesome people here :)

thanks buddy ...


Share this post


Link to post
Share on other sites

This doesn't work ?

$FileName = $path1 & $path2 
mciSendString('Open "' & $FileName & '" alias MediaFile')

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0