Jump to content

Error with checking if 2 pieces of data exist :-(


 Share

Recommended Posts

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

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

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

$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 by BrettF
Link to comment
Share on other sites

Yep you got it :mellow:

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 by jbennett
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...