Ptica Posted February 22, 2010 Posted February 22, 2010 Hello, I need help with reading ini file. I have the following: ini file: [settings] query= Select * from " & $servername & " where date=curdate()" Script: tried both: $queryLogger='"' & IniRead(@ScriptDir & "\" & $optionsFile, "settings", "query_logger", "")&'"' and $queryLogger=IniRead(@ScriptDir & "\" & $optionsFile, "settings", "query_logger", "") As a result I get : "SELECT * FROM " & $servername & " where date = curdate()" $servername is not resolved. If I write $queryLogger="SELECT * FROM " & $servername & " where date = curdate()", then I get the following string: SELECT * FROM MyServerName where date = curdate(). Could somebody explain what I'm doing wrong? I could not find the answer in the forum. Thanks in advance
AdmiralAlkex Posted February 22, 2010 Posted February 22, 2010 IniRead() returns a string, nothing more. It sounds to me like you need Execute(), try this: $servername = "iamonkey" $sTest = '"Select * from " & $servername & " where date=curdate()"' MsgBox(0, "", $sTest) MsgBox(0, "", Execute($sTest)) .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Mobius Posted February 22, 2010 Posted February 22, 2010 (edited) Ptica, #cs [settings] ; Notice the additional $ after the variable name, this is because of the Opt("ExpandVarStrings",1) line. query= Select * from $servername$ where date= $Curdate$ [] #ce Opt("ExpandVarStrings",1) $Servername = "AnyOldName" $CurDate = @MDAY &'/'& @MON &'/'& @YEAR $IniData = IniRead(@SCRIPTFULLPATH,"settings","query","fubar!") ConsoleWrite($IniData & @LF) *Shakes fist* beaten by the Admiral. Edited February 22, 2010 by Mobius
Ptica Posted February 23, 2010 Author Posted February 23, 2010 Ptica, #cs [settings] ; Notice the additional $ after the variable name, this is because of the Opt("ExpandVarStrings",1) line. query= Select * from $servername$ where date= $Curdate$ [] #ce Opt("ExpandVarStrings",1) $Servername = "AnyOldName" $CurDate = @MDAY &'/'& @MON &'/'& @YEAR $IniData = IniRead(@SCRIPTFULLPATH,"settings","query","fubar!") ConsoleWrite($IniData & @LF) *Shakes fist* beaten by the Admiral. Great! Thanks a lot, it worked! I had no chance to find this without your help. Cheers!
Ptica Posted February 23, 2010 Author Posted February 23, 2010 IniRead() returns a string, nothing more. It sounds to me like you need Execute(), try this: $servername = "iamonkey" $sTest = '"Select * from " & $servername & " where date=curdate()"' MsgBox(0, "", $sTest) MsgBox(0, "", Execute($sTest)) Wow, it works too. So many options to solve it and I could not find any. Thanks a lot for your help.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now