NELyon Posted January 13, 2008 Share Posted January 13, 2008 Well, I'm officially starting programming in Autoit again. My last UDF was just to get me going, and now I'm embarking on my first real project in over 6 Months. So the problem is, I'm creating a Favorites manager. It runs from a file based database, and each entry is RC4 encrypted. So, here's my problem. It reads from a file, Favorites.ftf, which is a file with the string "Favorites List" as the first line, and RC4 encrypted URLs as each line below. The problem is, the "Favorites List" entry gets added onto the list 2 or 3 times. The other entries appear fine. expandcollapse popup#Include <GUIConstants.au3> #Include <File.au3> #Include <String.au3> Global $favs ;Start by checking if the program has ran before If Not FileExists(@ScriptDir & "\Favorites.ftf") Then MsgBox(0, "Favoritizer", "This is either the first time running this program" & @CRLF & " Or you have deleted your definition file. A new one will be created") FileWrite(@ScriptDir & "\Favorites.ftf", "Favorites List" & @CRLF) EndIf $hGUI = GUICreate("Favoritizer 0.1 by Senton-Bomb", 500, 500) $Msg = GUICtrlCreateLabel("Welcome to Favoritizer! An easy-to-use Favorites organizer.", 0, 0) $bLoadDef = GUICtrlCreateButton("lReoad Favorites", 15, 450, 100) $ListOfDefs = GUICtrlCreateList("", 5, 100, 300, 300) $bNewDef = GUICtrlCreateButton("New Favorite", 180, 450, 100) GUISetState() _FileReadToArray(@ScriptDir & "\Favorites.ftf", $favs) For $i = 2 To $favs[0] $dcrpt = _StringEncrypt(0, $favs[$i], "autoitistehpwn") $str = $favs[1] & "|" & $dcrpt GUICtrlSetData($ListOfDefs, $str) Next While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE _Exit() Case $bLoadDef _FileReadToArray(@ScriptDir & "\Favorites.ftf", $favs) GUICtrlSetData($ListOfDefs, "") For $i = 2 To $favs[0] $dcrpt = _StringEncrypt(0, $favs[$i], "autoitistehpwn") $str = $favs[1] & "|" & $dcrpt GUICtrlSetData($ListOfDefs, $str) Next Case $bNewDef $tobe = InputBox("Favoritizer", "Enter a URL or file name to become a favorite", "http://autoitscript.com/forum") $ntobe = _StringEncrypt(1, $tobe, "autoitistehpwn") FileWrite(@ScriptDir & "\Favorites.ftf", $ntobe & @CRLF) Case Else Sleep(2) EndSwitch WEnd Func _Exit() GUIDelete($hGUI) MsgBox(0, "Favoritizer", "Thank you for using Favoritizer!") Exit EndFunc ;==>_Exit My OS is NimbleX Linux, emulating Windows 2000 on Autoit v3.2.10.0. Can anybody help me? Link to comment Share on other sites More sharing options...
NELyon Posted January 29, 2008 Author Share Posted January 29, 2008 Ok, i'm having a different problem now. I tried adding in a filter to remove any blank entries from the array (From the @CRLF when writing)The filter works, but it's broken my list updater. I get an 'Array variable has incorrect number of subscripts or subscript dimension range exceeded.: ' error. Here's my updated code:expandcollapse popup#include <GUIConstants.au3> #include <File.au3> #include <String.au3> #include <Array.au3> Global $favs ;Start by checking if the program has ran before If Not FileExists(@ScriptDir & "\Favorites.ftf") Then MsgBox(0, "Favoritizer", "This is either the first time running this program" & @CRLF & " Or you have deleted your definition file. A new one will be created") FileWrite(@ScriptDir & "\Favorites.ftf", "") EndIf $hGUI = GUICreate("Favoritizer 0.1 by Senton-Bomb", 500, 500) $Msg = GUICtrlCreateLabel("Welcome to Favoritizer! An easy-to-use Favorites organizer.", 0, 0) $bLoadDef = GUICtrlCreateButton("Reload Favorites", 15, 450, 100) $ListOfDefs = GUICtrlCreateList("", 5, 100, 300, 300) $bNewDef = GUICtrlCreateButton("New Favorite", 180, 450, 100) ControlFocus("", "", $Msg) GUISetState() _FileReadToArray(@ScriptDir & "\Favorites.ftf", $favs) For $z = 0 to $favs[0] If $favs[$z] = "" Then _ArrayDelete($favs, $z) EndIf Next ;~ _ArrayDisplay($favs) ;~ Exit ControlFocus("", "", $ListOfDefs) For $i = 1 To $favs[0] $dcrpt = _StringEncrypt(0, $favs[$i], "autoitistehpwn") $str = $dcrpt GUICtrlSetData($ListOfDefs, $str & "|") Next While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE _Exit() Case $bLoadDef _FileReadToArray(@ScriptDir & "\Favorites.ftf", $favs) ControlFocus("", "", $ListOfDefs) GUICtrlSetData($ListOfDefs, "") For $i = 1 To $favs[0] $dcrpt = _StringEncrypt(0, $favs[$i], "autoitistehpwn") $str = $dcrpt GUICtrlSetData($ListOfDefs, $str) Next Case $bNewDef $tobe = InputBox("Favoritizer", "Enter a URL or file name to become a favorite", "http://autoitscript.com/forum") $ntobe = _StringEncrypt(1, $tobe, "autoitistehpwn") FileWrite(@ScriptDir & "\Favorites.ftf", $ntobe & @CRLF) Case Else Sleep(2) EndSwitch WEnd Func _Exit() GUIDelete($hGUI) MsgBox(0, "Favoritizer", "Thank you for using Favoritizer!") Exit EndFunc ;==>_ExitIf you uncomment the _ArrayDisplay, you will see that the array displays fine. It has 2 elements, and the second element is the first line in the file, which in my case is:Favoritizer.ftf:692DB7AD55E1993A9FF773E71AF7A4A309A90990051B3908DF7EAF6FD60D84CEA80F9502A1A2F2DE724259E5D298F0642A98 7D442B9E767C084B(Which is http://autoitscript.com/forum encrypted with the password "autoitistehpwn")Does anyone know what's wrong? Link to comment Share on other sites More sharing options...
randallc Posted January 30, 2008 Share Posted January 30, 2008 Hi, Use 3.2.11.0? I think there was a bug in arraydelete empty arrays before?..... _ArrayDisplay($favs,"UBound($favs)="&UBound($favs)) ;~ Exit ControlFocus("", "", $ListOfDefs) For $i = 1 To UBound($favs)-1 ;~ For $i = 1 To $favs[0] Best, randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
NELyon Posted January 30, 2008 Author Share Posted January 30, 2008 Hi, Use 3.2.11.0? I think there was a bug in arraydelete empty arrays before?..... _ArrayDisplay($favs,"UBound($favs)="&UBound($favs)) ;~ Exit ControlFocus("", "", $ListOfDefs) For $i = 1 To UBound($favs)-1 ;~ For $i = 1 To $favs[0] Best, randall Perfect. I can't believe i didn't try that 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