Jump to content

quotes in file path problem


Go to solution Solved by michaelslamet,

Recommended Posts

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?

Link to comment
Share on other sites

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
Link to comment
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

Link to comment
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 :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...