Jump to content
Sign in to follow this  
jbennett

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

Recommended Posts

jbennett

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

Share this post


Link to post
Share on other sites
BrettF

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

Share this post


Link to post
Share on other sites
jbennett

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

Share this post


Link to post
Share on other sites
BrettF

$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

Share this post


Link to post
Share on other sites
jbennett

Here is an example of this section in the .ini with NAS as the type.

[DRIVE_TYPE]
type=NAS

Thanks

Edited by jbennett

Share this post


Link to post
Share on other sites
BrettF
jbennett

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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.