jbennett Posted November 7, 2008 Share Posted November 7, 2008 Hi everyone, I've got a problem with a piece of code and was wondering if someone could look at it for me. I'm trying to check some data in an .ini file and if either of the types doesn't exist then a messagebox will be displayed. But if one is available then my code just proceeds. $drive_type = IniRead(@scriptdir & "\Configuration.ini","DRIVE_TYPE", "type","") if not StringInStr($drive_type, "NAS")or if not StringInStr($drive_type, "REMOVABLE")then msgbox(16,"ERROR","Cannot determine your backup device." & @CRLF & "Please check Configuration.ini.",0) exit endif Thanks Link to comment Share on other sites More sharing options...
BrettF Posted November 7, 2008 Share Posted November 7, 2008 Your syntax is wrong. Do you have the full SciTe? If not download it, it has syntax checking. Makes your life a hell of a lot easier. $drive_type = "NAS" MsgBox (0, "", $drive_type) If Not StringInStr($drive_type, "NAS") Or Not StringInStr($drive_type, "REMOVABLE") Then MsgBox(16, "ERROR", "Cannot determine your backup device." & @CRLF & "Please check Configuration.ini.", 0) ;Exit EndIf $drive_type = "REMOVABLE AND NAS" MsgBox (0, "", $drive_type) If Not StringInStr($drive_type, "NAS") Or Not StringInStr($drive_type, "REMOVABLE") Then MsgBox(16, "ERROR", "Cannot determine your backup device." & @CRLF & "Please check Configuration.ini.", 0) ;Exit EndIf $drive_type = "REMOVABLE" MsgBox (0, "", $drive_type) If Not StringInStr($drive_type, "NAS") Or Not StringInStr($drive_type, "REMOVABLE") Then MsgBox(16, "ERROR", "Cannot determine your backup device." & @CRLF & "Please check Configuration.ini.", 0) ;Exit EndIf Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
jbennett Posted November 7, 2008 Author Share Posted November 7, 2008 Thanks I will have to check. I just tried the following and it didn't work..Hmm $drive_type = IniRead(@scriptdir & "\Configuration.ini","DRIVE_TYPE", "type","") MsgBox (0, "", $drive_type) If Not StringInStr($drive_type, "NAS") Or Not StringInStr($drive_type, "REMOVABLE") Then MsgBox(16, "ERROR", "Cannot determine your backup device." & @CRLF & "Please check Configuration.ini.", 0) ;Exit EndIf Link to comment Share on other sites More sharing options...
BrettF Posted November 7, 2008 Share Posted November 7, 2008 (edited) $drive_type = "NAS" MsgBox (0, "", $drive_type) If StringInStr($drive_type, "NAS") = 0 Or StringInStr($drive_type, "REMOVABLE") = 0 Then MsgBox(16, "ERROR", "Cannot determine your backup device." & @CRLF & "Please check Configuration.ini.", 0) ;Exit EndIf $drive_type = "REMOVABLE AND NAS" MsgBox (0, "", $drive_type) If StringInStr($drive_type, "NAS") = 0 Or StringInStr($drive_type, "REMOVABLE") = 0 Then MsgBox(16, "ERROR", "Cannot determine your backup device." & @CRLF & "Please check Configuration.ini.", 0) ;Exit EndIf $drive_type = "REMOVABLE" MsgBox (0, "", $drive_type) If StringInStr($drive_type, "NAS") = 0 Or StringInStr($drive_type, "REMOVABLE") = 0 Then MsgBox(16, "ERROR", "Cannot determine your backup device." & @CRLF & "Please check Configuration.ini.", 0) ;Exit EndIf Maybe? I don't have a crystal ball, none of us do... Post the content of a sample INI. Edited November 7, 2008 by BrettF Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
jbennett Posted November 7, 2008 Author Share Posted November 7, 2008 (edited) Here is an example of this section in the .ini with NAS as the type. [DRIVE_TYPE] type=NAS Thanks Edited November 7, 2008 by jbennett Link to comment Share on other sites More sharing options...
BrettF Posted November 7, 2008 Share Posted November 7, 2008 Lets put this logically- If the drive type is not NAS or Removeable then return error? Cheers. Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
jbennett Posted November 7, 2008 Author Share Posted November 7, 2008 (edited) Yep you got it cheers EDIT ---- hmm. I've found a solution. Does the following code seem Okay? $drive_type = IniRead(@scriptdir & "\Configuration.ini","DRIVE_TYPE", "type","") MsgBox (0, "", $drive_type) If StringInStr($drive_type, "NAS") Or StringInStr($drive_type, "LOCAL") Then ;proceeds to next part of code and doesn't display msgbox Else MsgBox(16, "ERROR", "Cannot determine your backup device." & @CRLF & "Please check Configuration.ini.", 0) exit EndIf Edited November 7, 2008 by jbennett Link to comment Share on other sites More sharing options...
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