Jump to content

This works but this don't work


 Share

Recommended Posts

Hi all you AutoIT users.

I have some kind of a funny problem.

This code works, with out problem

$read = GUICtrlRead($Treeview)
    if $Read = 0 Then
        MsgBox(64, "Delete Item", "Nothing to delete, list is empty or item not checked")
    EndIf
    
    FileDelete("C:\Test1.ini")
        
        For $i = 0 To UBound($ahsLines) - 1
            If BitAnd(GUICtrlRead($ahsLines[$i][1]), 1) Then 
                GUICtrlDelete($ahsLines[$i][1])
                $ahsLines[$i][1] = 0
            If Not FileExists("C:\Test1.ini") Then; 
                                        FileDelete("C:\Test.ini")
            FileWrite("C:\Test.ini", "")
            FileWrite("C:\Test1.ini", "")
            EndIf
                ContinueLoop
            Endif
            If $ahsLines[$i][1] Then FileWriteLine("C:\Test1.ini", $ahsLines[$i][0])
            FileCopy("C:\Test1.ini", "C:\Test.ini", 1)
            Next

But this code don't

$read = GUICtrlRead($Treeview)
    if $Read = 0 Then
        MsgBox(64, "Delete Item", "Nothing to delete, list is empty or item not checked")
    EndIf
    FileDelete(@ScriptDir & "\" & @UserName & ".tmp"); Deletes User Tmp file
            
        For $i = 0 To UBound($ahsLines) - 1
            If BitAnd(GUICtrlRead($ahsLines[$i][1]), 1) Then 
                GUICtrlDelete($ahsLines[$i][1])
                $ahsLines[$i][1] = 0
        If Not FileExists('"' & @ScriptDir & "\" & @UserName & ".tmp" & '"') Then       FileDelete(@ScriptDir & "\" & @UserName & ".dat")
        FileWrite(@scriptdir & "\" & @UserName & ".dat", "")
        FileWrite(@scriptdir & "\" & @UserName & ".tmp", "")
        EndIf
                ContinueLoop
            Endif
If $ahsLines[$i][1] Then FileWriteLine('"' & @scriptdir & "\" & @UserName & ".tmp" & '"', $ahsLines[$i][0])
        FileCopy(@scriptdir & "\" & @UserName & ".tmp", @scriptdir & "\" & @UserName & ".Dat", 1); Updates the originale file;-)
        Next

How can thet be, the only thing i have changed is the file to update/delete/write from C:\Test.ini / C:\Test1.ini to @ScriptDir & "\" & @UserName & ".Dat" / @ScriptDir & "\" & @UserName & ".Tmp"

My big problem is that i don't get the thing with arrayers yet, but i'm still learning :(

Hope that some of you great fokes can help me, with this little problem so i can get on with my script :(

Link to comment
Share on other sites

Well, I suck with arrays, so I can't help ya there :( But, is "FileDelete(@ScriptDir & "\" & @UserName & ".dat")" really a directory? To me it would maybe look like this if your script was in "C:\" and the username was "Bob J. Smith"

C:\Bob J. Smith.dat

Unless that's really a directory on your computer, I'm not too sure... :( Someone else probably knows.

FootbaG
Link to comment
Share on other sites

Well, I suck with arrays, so I can't help ya there :( But, is "FileDelete(@ScriptDir & "\" & @UserName & ".dat")" really a directory? To me it would maybe look like this if your script was in "C:\" and the username was "Bob J. Smith"

C:\Bob J. Smith.dat

Unless that's really a directory on your computer, I'm not too sure... :( Someone else probably knows.

<{POST_SNAPBACK}>

Weel in the start of my script i creates a file with FileWrite(@ScriptDir & "\" & @UserName & ".dat")
Link to comment
Share on other sites

But this code don't

$read = GUICtrlRead($Treeview)
    if $Read = 0 Then
        MsgBox(64, "Delete Item", "Nothing to delete, list is empty or item not checked")
    EndIf
    FileDelete(@ScriptDir & "\" & @UserName & ".tmp"); Deletes User Tmp file
            
        For $i = 0 To UBound($ahsLines) - 1
            If BitAnd(GUICtrlRead($ahsLines[$i][1]), 1) Then 
                GUICtrlDelete($ahsLines[$i][1])
                $ahsLines[$i][1] = 0
        If Not FileExists('"' & @ScriptDir & "\" & @UserName & ".tmp" & '"') Then        FileDelete(@ScriptDir & "\" & @UserName & ".dat")
        FileWrite(@scriptdir & "\" & @UserName & ".dat", "")
        FileWrite(@scriptdir & "\" & @UserName & ".tmp", "")
        EndIf
                ContinueLoop
            Endif
If $ahsLines[$i][1] Then FileWriteLine('"' & @scriptdir & "\" & @UserName & ".tmp" & '"', $ahsLines[$i][0])
        FileCopy(@scriptdir & "\" & @UserName & ".tmp", @scriptdir & "\" & @UserName & ".Dat", 1); Updates the originale file;-)
        Next

How can thet be, the only thing i have changed is the file to update/delete/write from C:\Test.ini / C:\Test1.ini to @ScriptDir & "\" & @UserName & ".Dat" / @ScriptDir & "\" & @UserName & ".Tmp"

My big problem is that i don't get the thing with arrayers yet, but i'm still learning  :(

Hope that some of you great fokes can help me, with this little problem so i can get on with my script  :(

<{POST_SNAPBACK}>

I think

If Not FileExists('"' & @ScriptDir & "\" & @UserName & ".tmp" & '"') Then

should be

If Not FileExists(@ScriptDir & "\" & @UserName & ".tmp") Then

and

If $ahsLines[$i][1] Then FileWriteLine('"' & @scriptdir & "\" & @UserName & ".tmp" & '"', $ahsLines[$i][0])

should be

If $ahsLines[$i][1] Then FileWriteLine(@scriptdir & "\" & @UserName & ".tmp", $ahsLines[$i][0])
Link to comment
Share on other sites

@SumTingWong

That i alsow have tryed

But i think that i might have found the error (not sure)

It seems that AutoIT dont work properly with ext. Dat when you do a filewrite thing, i'd alsow try som other ext. like .sbp, .dba, .set alsow there it did't work.

but i'm sure that there is a way out of that prob.

:EDIT

Hmm don't tell me how, but now i got it to work ??????????????

Edited by Rex
Link to comment
Share on other sites

Dammed why did i play Battleship in my english class :

Should'nt it be Damned? Dammed has a slightly different meaning :(:(

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

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