AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[TIP] IniRead Gotcha when using double quotes

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Lemming



Joined: 20 Dec 2005
Posts: 150
Location: Malaysia

PostPosted: Thu May 31, 2007 11:29 am    Post subject: [TIP] IniRead Gotcha when using double quotes Reply with quote

When using IniRead, double-quote marks will be discarded unless you escape them.

For example, if you have an ini file containing:

Code:
[IviewLocation]
IviewLocat="C:\Program Files\IrfanView\i_view32.exe"


And your script has this corresponding line:

Code:
IniRead, IviewLocat, Pict saver converter.ini, IviewLocation, IviewLocat


The variable IviewLocat will contain the string C:\Program Files\IrfanView\i_view32.exe (without double quotes). This would be fatal if I use it with command line stuff like:

Code:
RunWait %comspec% /c %IviewLocat% %filein% /one %ResizeVal% /aspectratio /resample /sharpen=1 /jpgq=92 %fileout%


Pathnames and filenames that contain spaces must be enclosed in double quotes.

The solution is to use two double-quotes within the ini file, i.e.:

Code:
[IviewLocation]
IviewLocat=""C:\Program Files\IrfanView\i_view32.exe""


Also refer to AHK Escape Sequences:
http://www.autohotkey.com/docs/commands/_EscapeChar.htm


Last edited by Lemming on Tue Jun 05, 2007 5:19 am; edited 1 time in total
Back to top
View user's profile Send private message
Helpy
Guest





PostPosted: Thu May 31, 2007 12:06 pm    Post subject: Reply with quote

You might want to change ReadIni to IniRead in the subject...
Note this has been mentioned recently in IniRead-ing values between quotes.. quotes disappear.
Back to top
Lemming



Joined: 20 Dec 2005
Posts: 150
Location: Malaysia

PostPosted: Tue Jun 05, 2007 5:20 am    Post subject: Reply with quote

whoops, you're right. IniRead it is. Changes made.
[Moderator's note: Also added [TIP] flag to make it stand out and ease searches.]
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group