mircea Posted May 9, 2011 Share Posted May 9, 2011 Well, hello guys, i was hopping to find out myself with searching and other stuff but seems im out of luck, so.. i made an aplication were users that have accounts (can make other accounts and those accounts can make again other accounts) and after that they can repair or add it to defect some item (i called emulator). I have now the following issue, im trying to make a log file were everything that someone did in the aplication will be logged for example Ex. Mircea has logged at 3 p.m mircea repaired 2 emulators for example and stuff like this. mircea created 2 new accounts (and there name). now whats the major problem. I tried to make the log file with the script that SmOke_N provide me Ini Crypt, but it seems that i'm a bit limited cause for example ex. 09.05.2011.log [mircea] hour = 7.41 p.m Made new account = new_account How many Repaired = 2 emulators What pieces did i change = a wire Series of emulator = 0001 This is the way i was thinking in the first place, but i had some problems, if i tried to add something new, for example another account it rewrites the old values, and i don't want that. I was thinking to use the _filewritelog but that is not exacly what im searching for, cause the main reason is i want that everyone can see he's log only it shows only what he did, and a Big button log were it shows everything that everyone did. Could you guys give me some clues or some idea how could i start? the code for the full aplication is expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Crypt.au3> #include <Date.au3> #include <file.au3> #include <array.au3> #include <string.au3> #comments-start Probleme 1 trebuie gasita o modalitate de a scris defecte si repair 2 trebuei gasita o modalitate de encriptare a fisierelor log si de a face un main log si backup log(in caz de il manca pe careva in fund) 3 pentru log vom folosi metoda de ini crypt 3 de a face 2 fisierele de ini si dupa aia sa le compare in caz de cineva le-a modificat fisierul, sau nush probabil sa fie trecut doar in fisierul de log ramane de gandita treaba #comments-end Global $criptarekey = "parolasuperultrasecreta" Global $x=StringReplace(_NowDate(), '/', '-') Global $timp = _nowtime(3) Global $passlevel = "1" ;; inceput de LogIn $LoginForm = GUICreate("Enter Username & Password", 298, 170, -1, -1) $LogInput = GUICtrlCreateInput("", 8, 40, 241, 21) $LogInPass = GUICtrlCreateInput("", 8, 96, 241, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $OkLogin = GUICtrlCreateButton("&OK", 86, 128, 75, 25, $BS_NOTIFY) $ExitLogIn = GUICtrlCreateButton("Exit", 167, 128, 75, 25, $BS_NOTIFY) $EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 68, 77, 17, 0) $LogUsername = GUICtrlCreateLabel("Enter Username", 8, 16, 80, 17) GUISetState(@SW_SHOW) ;; parola si username-ul e 1 cifra 1 While 1 $citescini2 = IniReadSectionNames("accounts.ini") $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $okLogin if ControlGetText("","",$loginpass) = "" or ControlGetText("","",$loginput) = "" then msgbox(0,"Error", "Username/Password can't be blank") Else Global $decriptareuser = _StringEncrypt(1,Guictrlread($Loginput),$criptarekey,$passlevel) If Not _ArrayFindAll($citescini2,$decriptareuser) Then $xa = IniReadSection($citescini2,$Decriptareuser) $decriptarepass = _StringEncrypt(1,guictrlread($loginpass),$criptarekey,$passlevel) Global $loginn = _StringEncrypt(0,$decriptareuser,$criptarekey,$passlevel) ;;username-ul celui care s-a logat If ControlGetText("","",$loginpass) = "" Then MsgBox(4096, "Error", "Password must not be left blank!") ExitLoop ElseIf $xa[1][1] = $decriptarepass Then Guidelete($LoginForm) ;; inceput de main $Main = GUICreate("Emulator Repair v.0.7", 283, 198, 204, 135) Global $Username = GUICtrlCreateLabel($loginn& ":Has logged in", 8, 16, 124, 17) ;;aici arata numele $Change = GUICtrlCreateButton("Change Password", 144, 8, 97, 25) Global $EmulatorSerial = GUICtrlCreateInput("", 8, 56, 257, 21) $Read = GUICtrlCreateButton("Read", 8, 96, 73, 25) $Emulator = GUICtrlCreateButton("Emulator", 96, 96, 81, 25) $Addnewusername = GUICtrlCreateButton("Add New Username", 80, 136, 105, 33) $Logs = GUICtrlCreateButton("Logs", 192, 96, 73, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Read Msgbox(0,"Testat","Testat") Case $Change ;; buton change password GUISetState(@SW_DISABLE, $Main) ;; Inceput Cod Change password $PasswordForm = GUICreate("Change Password", 259, 211, -1, -1) $PasswordOld = GUICtrlCreateInput("", 8, 32, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $PasswdOk = GUICtrlCreateButton("&OK", 38, 168, 75, 25, $BS_NOTIFY) $PasswdCancel = GUICtrlCreateButton("&Cancel", 127, 168, 75, 25, $BS_NOTIFY) $EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 12, 77, 17, 0) $Passwordnew = GUICtrlCreateInput("", 8, 88, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $Passwordnew2 = GUICtrlCreateInput("", 8, 136, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $Passwordnewlabel = GUICtrlCreateLabel("Enter the new password", 8, 64, 118, 17) $passwordnewlabel2 = GUICtrlCreateLabel("Repeat the new password", 8, 112, 128, 17) GUISetState(@SW_SHOW) While 1 $citescini3 = IniReadSectionNames("accounts.ini") $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $PasswdCancel ExitLoop Case $passwdok Global $parolaveche = IniReadSection("accounts.ini",$decriptareuser) msgbox(0,"Test",$parolaveche[1][1]) ; for checking if it's read the new password $codareparola = _StringEncrypt(1,Guictrlread($Passwordold),$criptarekey,$passlevel) if ControlGetText("","",$PasswordOld) = "" or ControlGetText("","",$passwordnew2) = "" or ControlGetText("","",$passwordnew) = "" then msgbox (0,"Error", "You can't leave blank any input box") Else If Not _ArrayFindAll($citescini3,$decriptareuser) Then msgbox(0,"Am ajuns","am ajuns") ; [this step works if $parolaveche[1][1] = $codareparola Then ;this step works Msgbox(0,"oau", "Merge verificat parola veche cu actuala") if Guictrlread($Passwordnew) = guictrlread($passwordnew2) Then msgbox(0,"Oau","E la fel nu e gresita") ; [this step works] $citescnouaparola = guictrlread($passwordnew2) $scriunouaparola = _StringEncrypt(1,$citescnouaparola,$criptarekey,$passlevel) msgbox(0,"hmmm",$scriunouaparola) ; checking if it's working msgbox(0,"asd",$decriptareuser) ; checking if its working iniwritesection("accounts.ini",$decriptareuser,"password = " & $scriunouaparola) ; here it's my main problem, i dont understand why it dosen't write in the ini file msgbox(0,"am scris","am scris noua parola") Else msgbox(0,"shit","nu nu merge") Endif Else msgbox(0,"oau", "nu merge ai scris gresit") Endif endif endif EndSwitch WEnd ;;sfarsit buton de change GUISetState(@SW_ENABLE, $Main) GUIDelete($PasswordForm) case $Emulator ;; Inceput cod Emulator GUISetState(@SW_DISABLE, $Main) $timp2 = _nowtime() $Emulators = GUICreate("Emulators", 617, 136, 278, 730) $Nume = GUICtrlCreateLabel("Nume", 48, 8, 32, 17) $Data = GUICtrlCreateLabel("Data", 160, 8, 27, 17) $Ora = GUICtrlCreateLabel("Ora", 248, 8, 21, 17) $SerieEmulator = GUICtrlCreateLabel("Seria Emulatorului", 328, 8, 88, 17) $Reparat = GUICtrlCreateLabel("Reparat", 440, 8, 42, 17) $Defect = GUICtrlCreateLabel("Defect", 496, 8, 36, 17) $NumeInput = GUICtrlCreateInput($loginn, 8, 32, 113, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) ;; numele se va lua automat de la LogIN (cand persoana respectiva se logheaza) $DataInput = GUICtrlCreateInput($x, 136, 32, 73, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) ;; data curenta cand face modificarea $OraInput = GUICtrlCreateInput($timp2, 232, 32, 65, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) ;; ora curenta cand face modificarea $SeriaInput = GUICtrlCreateInput(Guictrlread($EmulatorSerial), 312, 32, 113, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) ;; serialul care l-a folosit la main $AddDefect = GUICtrlCreateButton("Add", 56, 72, 81, 25) $CancelEmulator = GUICtrlCreateButton("Cancel", 160, 72, 105, 25) $MyLogs = GUICtrlCreateButton("My Logs", 288, 72, 81, 25) $ReparatBox = GUICtrlCreateRadio("", 448, 32, 17, 17) $DefectBox = GUICtrlCreateRadio("", 504, 32, 17, 17) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $CancelEmulator Exitloop Case $addDefect if Guictrlread($seriainput) = "" Then Msgbox(0,"Error","You didn't scan the serial of the emulator") Else msgbox(0,"test",$Defectinput) ;aici trebuie sa verificam daca Reparat radio sau Defect Radio are date sau nu, daca nu are apare eroare ca nu are si trebuie introduse ;pentru loguri vom folosi comanda _FileWriteLog endif Case $Reparatbox ;; inceput cod Reparat GUISetState(@SW_DISABLE, $Emulators) $Reparatform = GUICreate("Reparat", 412, 482, 302, 218) $ReparatLabel = GUICtrlCreateLabel("Reparat", 32, 16, 89, 33) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $DefectLabel = GUICtrlCreateLabel("Defect", 32, 72, 43, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") Global $Defectinput = GUICtrlCreateInput("", 144, 72, 201, 21) $PiesaLabel = GUICtrlCreateLabel("Piesa Schimbata 1", 32, 104, 92, 17) $PiesaInput1 = GUICtrlCreateInput("", 144, 104, 201, 21) $PiesaLabel2 = GUICtrlCreateLabel("Piesa Schimbata 2", 32, 136, 92, 17) $PiesaInput2 = GUICtrlCreateInput("", 144, 136, 201, 21) $PiesaLabel3 = GUICtrlCreateLabel("Piesa Schimbata 3", 32, 168, 92, 17) $PiesaInput3 = GUICtrlCreateInput("", 144, 168, 201, 21) $Repara = GUICtrlCreateButton("Reparat", 88, 440, 97, 25) $Anuleaza = GUICtrlCreateButton("Anuleaza", 232, 440, 105, 25) $Testat = GUICtrlCreateRadio("Testat", 56, 200, 65, 25) $Netestat = GUICtrlCreateRadio("Netestat", 136, 200, 73, 25) $InformatiiRepair = GUICtrlCreateEdit("", 72, 232, 273, 193, BitOR($ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_HSCROLL,$WS_VSCROLL)) GUISetState(@SW_SHOW) GUICtrlSetState($Testat, $GUI_CHECKED) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $Anuleaza ExitLoop Case $repara if ControlGetText("","",$DefectInput) = "" or ControlGetText("","",$InformatiiRepair) = "" Then msgbox(0,"Error","You have to introduce Defect/Information in the edit table") Else ; here it will starts the writing the log files what i have write . if guictrlread($testat) = $GUI_CHECKED then msgbox(0,"Testat","A Fost testat") iniwrite($X&".log",$loginn,"Testat", Else If guictrlread($netestat) = $GUI_CHECKED then msgbox(0,"netestat","A fost netestat") endif EndIf Endif EndSwitch WEnd ;;Sfarsit Cod Reparat GUISetState(@SW_ENABLE, $Emulators) GUIDelete($ReparatForm) Case $DefectBox ;;Defect box GUISetState(@SW_DISABLE, $Emulators) $Defectform = GUICreate("Defect Form", 405, 396, 757, 401) $DefecLabel = GUICtrlCreateLabel("Add Defect", 32, 16, 122, 33) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $DefectLabel = GUICtrlCreateLabel("Defect", 32, 72, 43, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Defectinput = GUICtrlCreateInput("", 104, 72, 273, 21) $Informatiilabel = GUICtrlCreateLabel("Informations", 32, 128, 61, 17) GUICtrlCreateEdit("", 104, 128, 273, 193, BitOR($ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_HSCROLL,$WS_VSCROLL)) $AddDefect = GUICtrlCreateButton("Add Defect", 120, 352, 73, 25) $CancelDefect = GUICtrlCreateButton("Cancel", 256, 352, 73, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $cancelDefect exitloop EndSwitch WEnd GUISetState(@SW_ENABLE, $Emulators) GUIDelete($DefectForm) ;;Sfarsit defectbox ;Case $Mylogs ;; inceput pt mylogs EndSwitch WEnd ;;Sfarsit cod Emulator GUISetState(@SW_ENABLE, $Main) GUIDelete($Emulators) Case $Addnewusername GUISetState(@SW_DISABLE, $Main) ;; inceput newuserform $NewUser = GUICreate("New username", 209, 188, -1, -1) $newuserinput = GUICtrlCreateInput("", 8, 40, 185, 21) $newpassinput = GUICtrlCreateInput("", 8, 96, 185, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $Createnewuser = GUICtrlCreateButton("&OK", 14, 128, 75, 25, $BS_NOTIFY) $Cancelnewuser = GUICtrlCreateButton("&Cancel", 111, 128, 75, 25, $BS_NOTIFY) $EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 68, 77, 17, 0) $newusername = GUICtrlCreateLabel("Enter New Username", 8, 16, 105, 17) GUISetState(@SW_SHOW) $citescini=IniReadSectionNames("accounts.ini") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop case $cancelnewuser Exitloop case $createnewuser if ControlGetText("","",$newuserinput) = "" or ControlGetText("","",$newpassinput) = "" then msgbox(0,"Error", "Username/Password can't be blank") Else $Criptatuser = _StringEncrypt(1,Guictrlread($newuserinput),$criptarekey,$passlevel) If _ArrayFindAll($citescini,$Criptatuser) Then $Criptatpass = _StringEncrypt(1,Guictrlread($newpassinput),$Criptarekey,$passlevel) $a = IniWriteSection("accounts.ini",$criptatuser, "password = " & $criptatpass) MsgBox( 4096, "Succes", "Username successfully created") #comments-start iniwrite($x&".log","accounts",$loginn,guictrlread($newuserinput)) The command for loggin we have to thing a way to make this work ... #comments-end Else MsgBox( 4096, "Username Found", "This username is allready in use") EndIf Endif EndSwitch WEnd GUISetState(@SW_ENABLE, $Main) GUIDelete($Newuser) ;;sfarsit newuser form EndSwitch WEnd ;;Sfarsit main Else msgbox(0,"Error","Wrong Password/username") Endif Else msgbox(0,"Error","Wrong username/password") EndIf Endif case $exitLogIn Exit EndSwitch WEnd ;;Sfarsit de log in Link to comment Share on other sites More sharing options...
enaiman Posted May 9, 2011 Share Posted May 9, 2011 Well you definitely have a lot of work on your hands with this project. The ini approach might not be the best one. The example shows that you used your username as a section name. That section name will be the same so the keys will be overwritten everytime you add something and that's not good. I think you might be better to use a *.csv file. Just use your user name as the first value, time - 2nd value, new account - 3rd value ... and so on Everytime you do something, a new line will be added to the csv file - that will prevent overwriting the old data. Make an unique csv file and keep it somewhere "not in plain sight" - you can also implement a "backup" feature (copy the file to a backup folder just before writing) - or you can make a copy of the file after your script wrote a new entry, and compare the file with the copy before writing to it next time ... plenty of ideas here. To show everybody only his/her part: make your script read from the csv file only the lines starting with their username. Handle this through the script and don't let the users actually tamper with the csv file. Well, I guess you can always have a chat with taietel - he's from Cluj (sorry taietel if I'm wrong ) and he might agree to help you. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
mircea Posted May 10, 2011 Author Share Posted May 10, 2011 Yes i agree with you @enaiman, with the section part, but i just had a dream (i wake up 5 minutes ago) and i was thinking to replace the section value with the hour:minute:secound) ex. 09.41 a.m 20 sec) or something close to this, but you really got my atention with the .csv file. I searched the help file and i found it's something with excel. Well the only problem that i think i my have is can i make or read a .csv file without having installed excel suite? Hmmmm seems i found a way to protect the csv file with the _excel_saveass. Well i will try the excel command and see how does it work. I hope i will have no problems (finger cross) Thank you @enaiman for the help with the .csv file $sPassword [optional] The string password to protect the sheet with; if blank, no password will be used (default = blank) $sWritePassword [optional] The string write-access password to protect the sheet with; if blank, no password will be used (default = blank) Link to comment Share on other sites More sharing options...
enaiman Posted May 10, 2011 Share Posted May 10, 2011 csv = Comma Separated Values (romanian: valori separate prin virgule)Basically, a csv file is a text file where values are separated by commas. This format can be opened automatically by Excel which will put the info in rows and columns.You can create, read, save a csv file without Excel being installed - just as you would do with any text file.Just decide on a structure for the file and after that it will be very easy:Line template: Username,Time,NewAccount,Repaired,Changes,SerialNumbersActual line in the file:Mircea,7:41 p.m,new_account,2 emulators,1x wire,0001When you read this line, by using StringSplit for "," it will put all the elements into an array.You need to take care that no extra commas are in the entries or it will screw up the formatting.Alternately, you can use something else as delimiter like "|" or whatever else. As I said: plenty of ideas. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
mircea Posted May 11, 2011 Author Share Posted May 11, 2011 Something like what you said i was thinking, but seems im stuck with a problem. How can i protect the file? or better said what commands do i use. i made this type of script of course it's not done but i want to mark the ideea that the script usually needs excel, but i found out that it's not a problem cause i can install excel on the pc were i want to put the program, the tricky part is how do i protect the information. I had think at that too with _string encrypt so thats not a problem, but i seen that the _Excel function has some protections, i tried them to put a password on the .csv or .xsl but i can enter easy in the file, change everything i want . And another thing that i don't understant why does it load my excel file and i can see the information in the file when i write the log? i tried to put 0 at _excelboonew(0) but ok, it dosen't show at start it shows at the end. While 1 $nMsg = GUIGetMsg() $citescini=IniReadSectionNames($x&".ini") Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop case $cancelnewuser Exitloop case $createnewuser if ControlGetText("","",$newuserinput) = "" or ControlGetText("","",$newpassinput) = "" then msgbox(0,"Error", "Username/Password can't be blank") Else $Criptatuser = _StringEncrypt(1,Guictrlread($newuserinput),$criptarekey,1) If _ArrayFindAll($citescini,$Criptatuser) Then $Criptatpass = _StringEncrypt(1,Guictrlread($newpassinput),$Criptarekey,1) $a = IniWriteSection($x&".ini",$criptatuser, "password = " & $criptatpass) MsgBox( 4096, "User Doesn't Exist", "success") $excel = _ExcelBookNew(0) _ExcelWriteCell($excel,"nume",1,1) _ExcelWriteCell($excel,"parola",1,2) _ExcelWriteCell($excel,$criptatuser,2,1) _excelwritecell($excel,$criptatpass,2,2) _ExcelBookSaveAs($excel,"c:\Emulator readers\criptare.decriptare\temp.csv","csv","Testpasswd","testpass") _ExcelBookClose($excel,1,0) Link to comment Share on other sites More sharing options...
hannes08 Posted May 11, 2011 Share Posted May 11, 2011 Hi mircea, your csv file is not password protected because the fileformat does not suppot it (unlike .xls files). You coudl write your own GUI, that rereads your csv file periodically and displays only what you want (one or all users). enaiman already said that you do not need to use excel to read it. Another approach could be to use a small database (SQLite) where you can easily filter and search values. At least it is better than working with text files (and that's what csv files basically are). Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
mircea Posted May 11, 2011 Author Share Posted May 11, 2011 That what i was trying to make in the first place with sqlite cause thats easy i don't need any encryption cause everything it between the sqlite server and the program interface. Hmmm im going to think and come with feedback what i have done. Link to comment Share on other sites More sharing options...
mircea Posted May 12, 2011 Author Share Posted May 12, 2011 Hello guys, First things firt, i want to thank you @hannes123 and @enaiman with the briliant ideea for .csv it's absolutley genius. But i have again some dificulties. I made the program to write logs when a username creates a username, when he add a emulator (Repaired or DefecT) i done almost everything now it seems that im stuck with searching. The ideea that i want to make is when i press myLogs to show what i have done and when i press Logs to show what i have done and everyone else that have done something. Could you guys help me ? Thank you the .ini file the username is 1 and password 1 [9C40] password = 9C40 Here is the full code with logging. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Crypt.au3> #include <Date.au3> #include <file.au3> #include <array.au3> #include <string.au3> #comments-start Probleme 1 trebuie gasita o metoda pentru search #comments-end Global $criptarekey = "parolasuperultrasecreta" Global $x=StringReplace(_NowDate(), '/', '-') Global $timp = _nowtime(3) Global $passlevel = "1" Global $output_file = @ScriptDir & "\" & $X &".csv" ;; inceput de LogIn $LoginForm = GUICreate("Enter Username & Password", 298, 170, -1, -1) $LogInput = GUICtrlCreateInput("", 8, 40, 241, 21) $LogInPass = GUICtrlCreateInput("", 8, 96, 241, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $OkLogin = GUICtrlCreateButton("&OK", 86, 128, 75, 25, $BS_NOTIFY) $ExitLogIn = GUICtrlCreateButton("Exit", 167, 128, 75, 25, $BS_NOTIFY) $EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 68, 77, 17, 0) $LogUsername = GUICtrlCreateLabel("Enter Username", 8, 16, 80, 17) GUISetState(@SW_SHOW) ;; parola si username-ul e 1 cifra 1 While 1 ; se verifica passwordul $citescini2 = IniReadSectionNames("accounts.ini") $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $okLogin if ControlGetText("","",$loginpass) = "" or ControlGetText("","",$loginput) = "" then msgbox(0,"Error", "Username/Password can't be blank") Else Global $decriptareuser = _StringEncrypt(1,Guictrlread($Loginput),$criptarekey,$passlevel) If Not _ArrayFindAll($citescini2,$decriptareuser) Then $xa = IniReadSection($citescini2,$Decriptareuser) $decriptarepass = _StringEncrypt(1,guictrlread($loginpass),$criptarekey,$passlevel) Global $loginn = _StringEncrypt(0,$decriptareuser,$criptarekey,$passlevel) ;;username-ul celui care s-a logat If ControlGetText("","",$loginpass) = "" Then MsgBox(4096, "Error", "Password must not be left blank!") ExitLoop ElseIf $xa[1][1] = $decriptarepass Then ; pass-ul e trecut Guidelete($LoginForm) ;; inceput de main $Main = GUICreate("Emulator Repair v.0.7", 283, 198, 204, 135) Global $Username = GUICtrlCreateLabel($loginn& ":Has logged in", 8, 16, 124, 17) ;;aici arata numele $Change = GUICtrlCreateButton("Change Password", 144, 8, 97, 25) Global $EmulatorSerial = GUICtrlCreateInput("", 8, 56, 257, 21) $Read = GUICtrlCreateButton("Read", 8, 96, 73, 25) $Emulator = GUICtrlCreateButton("Emulator", 96, 96, 81, 25) $Addnewusername = GUICtrlCreateButton("Add New Username", 80, 136, 105, 33) $Logs = GUICtrlCreateButton("Logs", 192, 96, 73, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Read Msgbox(0,"Testat","Testat") Case $Change ;; buton change password GUISetState(@SW_DISABLE, $Main) ;; Inceput Cod Change password $PasswordForm = GUICreate("Change Password", 259, 211, -1, -1) $PasswordOld = GUICtrlCreateInput("", 8, 32, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $PasswdOk = GUICtrlCreateButton("&OK", 38, 168, 75, 25, $BS_NOTIFY) $PasswdCancel = GUICtrlCreateButton("&Cancel", 127, 168, 75, 25, $BS_NOTIFY) $EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 12, 77, 17, 0) $Passwordnew = GUICtrlCreateInput("", 8, 88, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $Passwordnew2 = GUICtrlCreateInput("", 8, 136, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $Passwordnewlabel = GUICtrlCreateLabel("Enter the new password", 8, 64, 118, 17) $passwordnewlabel2 = GUICtrlCreateLabel("Repeat the new password", 8, 112, 128, 17) GUISetState(@SW_SHOW) While 1 $citescini3 = IniReadSectionNames("accounts.ini") $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $PasswdCancel ExitLoop Case $passwdok ;inceput de schimbare parola Global $parolaveche = IniReadSection("accounts.ini",$decriptareuser) msgbox(0,"Test",$parolaveche[1][1]) ; for checking if it's read the new password $codareparola = _StringEncrypt(1,Guictrlread($Passwordold),$criptarekey,$passlevel) if ControlGetText("","",$PasswordOld) = "" or ControlGetText("","",$passwordnew2) = "" or ControlGetText("","",$passwordnew) = "" then msgbox (0,"Error", "You can't leave blank any input box") Else If Not _ArrayFindAll($citescini3,$decriptareuser) Then if $parolaveche[1][1] = $codareparola Then ;this step works if Guictrlread($Passwordnew) = guictrlread($passwordnew2) Then $citescnouaparola = guictrlread($passwordnew2) $scriunouaparola = _StringEncrypt(1,$citescnouaparola,$criptarekey,$passlevel) iniwritesection("accounts.ini",$decriptareuser,"password = " & $scriunouaparola) ; here it's my main problem, i dont understand why it dosen't write in the ini file MsgBox(0,"Succes","The password has bin changed") Else msgbox(0,"Error","The new password dosen't match") Endif Else msgbox(0,"Error", "The password dosen't match") Endif endif endif ; sfarsit de schimbare parola EndSwitch WEnd ;;sfarsit buton de change GUISetState(@SW_ENABLE, $Main) GUIDelete($PasswordForm) case $Emulator ;; Inceput cod Emulator GUISetState(@SW_DISABLE, $Main) $timp2 = _nowtime() $Emulators = GUICreate("Emulators", 617, 136, 278, 730) $Nume = GUICtrlCreateLabel("Nume", 48, 8, 32, 17) $Data = GUICtrlCreateLabel("Data", 160, 8, 27, 17) $Ora = GUICtrlCreateLabel("Ora", 248, 8, 21, 17) $SerieEmulator = GUICtrlCreateLabel("Seria Emulatorului", 328, 8, 88, 17) $Reparat = GUICtrlCreateLabel("Reparat", 440, 8, 42, 17) $Defect = GUICtrlCreateLabel("Defect", 496, 8, 36, 17) Global $NumeInput = GUICtrlCreateInput($loginn, 8, 32, 113, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) ;; numele se va lua automat de la LogIN (cand persoana respectiva se logheaza) $DataInput = GUICtrlCreateInput($x, 136, 32, 73, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) ;; data curenta cand face modificarea $OraInput = GUICtrlCreateInput($timp2, 232, 32, 65, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) ;; ora curenta cand face modificarea $SeriaInput = GUICtrlCreateInput(Guictrlread($EmulatorSerial), 312, 32, 113, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) ;; serialul care l-a folosit la main $AddDefect = GUICtrlCreateButton("Add", 56, 72, 81, 25) $CancelEmulator = GUICtrlCreateButton("Cancel", 160, 72, 105, 25) $MyLogs = GUICtrlCreateButton("My Logs", 288, 72, 81, 25) $ReparatBox = GUICtrlCreateRadio("", 448, 32, 17, 17) $DefectBox = GUICtrlCreateRadio("", 504, 32, 17, 17) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $CancelEmulator Exitloop Case $addDefect if Guictrlread($seriainput) = "" Then Msgbox(0,"Error","You didn't scan the serial of the emulator") ;Else ; aici ar mai trebui gandit... pana acuma habar nu am cum sa facem .... dar ramane de vazut endif Case $Reparatbox ;; inceput cod Reparat GUISetState(@SW_DISABLE, $Emulators) $Reparatform = GUICreate("Reparat", 412, 482, 302, 218) $ReparatLabel = GUICtrlCreateLabel("Reparat", 32, 16, 89, 33) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $DefectLabel = GUICtrlCreateLabel("Defect", 32, 72, 43, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") Global $Defectinput = GUICtrlCreateInput("", 144, 72, 201, 21) $PiesaLabel = GUICtrlCreateLabel("Piesa Schimbata 1", 32, 104, 92, 17) $PiesaInput1 = GUICtrlCreateInput("", 144, 104, 201, 21) $PiesaLabel2 = GUICtrlCreateLabel("Piesa Schimbata 2", 32, 136, 92, 17) $PiesaInput2 = GUICtrlCreateInput("", 144, 136, 201, 21) $PiesaLabel3 = GUICtrlCreateLabel("Piesa Schimbata 3", 32, 168, 92, 17) $PiesaInput3 = GUICtrlCreateInput("", 144, 168, 201, 21) $Repara = GUICtrlCreateButton("Reparat", 88, 440, 97, 25) $Anuleaza = GUICtrlCreateButton("Anuleaza", 232, 440, 105, 25) $Testat = GUICtrlCreateRadio("Testat", 56, 200, 65, 25) $Netestat = GUICtrlCreateRadio("Netestat", 136, 200, 73, 25) $InformatiiRepair = GUICtrlCreateEdit("", 72, 232, 273, 193, BitOR($ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_HSCROLL,$WS_VSCROLL)) GUISetState(@SW_SHOW) GUICtrlSetState($Testat, $GUI_CHECKED) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $Anuleaza ExitLoop Case $repara if ControlGetText("","",$DefectInput) = "" or ControlGetText("","",$InformatiiRepair) = "" Then msgbox(0,"Error","You have to introduce Defect/Information in the edit table") Else ; here it will starts the writing the log files what i have write . if guictrlread($testat) = $GUI_CHECKED then ;if it;s tested the emulator tabellog() local $log_testat[1][15] $log_testat[0][0] = Guictrlread($numeInput) $log_testat[0][1] = Guictrlread($dataInput) $log_testat[0][2] = Guictrlread($orainput) $log_testat[0][3] = guictrlread($seriainput) $log_Testat[0][4]= "TRUE" $log_testat[0][5] = Guictrlread($Defectinput) $log_testat[0][6] = Guictrlread($PiesaInput1) $log_testat[0][7] = Guictrlread($PiesaInput2) $log_testat[0][8] = Guictrlread($PiesaInput3) $log_testat[0][9] = "TRUE" $log_testat[0][10] = "--" $log_testat[0][11] = Guictrlread($InformatiiRepair) $log_testat[0][12] = "FALSE" $log_testat[0][13] = "--" $log_testat[0][14] = "--" ;_ArrayDisplay($log_testat) $rows = UBound($log_testat) - 1 $columns = UBound($log_testat, 2) -1 For $i = 0 To $rows $sLine = "" For $j = 0 To $columns $sLine &= $log_testat[$i][$j] & ";" Next FileWriteLine($output_file, StringTrimRight($sLine, 1)) Next Else If guictrlread($netestat) = $GUI_CHECKED then ; IF it's not tested the emulator tabellog() local $log_testat[1][15] $log_testat[0][0] = Guictrlread($numeInput) $log_testat[0][1] = Guictrlread($dataInput) $log_testat[0][2] = Guictrlread($orainput) $log_testat[0][3] = guictrlread($seriainput) $log_Testat[0][4]= "TRUE" $log_testat[0][5] = Guictrlread($Defectinput) $log_testat[0][6] = Guictrlread($PiesaInput1) $log_testat[0][7] = Guictrlread($PiesaInput2) $log_testat[0][8] = Guictrlread($PiesaInput3) $log_testat[0][9] = "--" $log_testat[0][10] = "TRUE" $log_testat[0][11] = Guictrlread($InformatiiRepair) $log_testat[0][12] = "--" $log_testat[0][13] = "--" $log_testat[0][14] = "--" ;_ArrayDisplay($log_testat) $rows = UBound($log_testat) - 1 $columns = UBound($log_testat, 2) -1 For $i = 0 To $rows $sLine = "" For $j = 0 To $columns $sLine &= $log_testat[$i][$j] & ";" Next FileWriteLine($output_file, StringTrimRight($sLine, 1)) Next endif EndIf Endif EndSwitch WEnd ;;Sfarsit Cod Reparat GUISetState(@SW_ENABLE, $Emulators) GUIDelete($ReparatForm) Case $DefectBox ;;Defect box GUISetState(@SW_DISABLE, $Emulators) $Defectform = GUICreate("Defect Form", 405, 396, 757, 401) $DefecLabel = GUICtrlCreateLabel("Add Defect", 32, 16, 122, 33) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $DefectLabel = GUICtrlCreateLabel("Defect", 32, 72, 43, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Defectinput = GUICtrlCreateInput("", 104, 72, 273, 21) $Informatiilabel = GUICtrlCreateLabel("Informations", 32, 128, 61, 17) $informatiidefect = GUICtrlCreateEdit("", 104, 128, 273, 193, BitOR($ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_HSCROLL,$WS_VSCROLL)) $AddDefect = GUICtrlCreateButton("Add Defect", 120, 352, 73, 25) $CancelDefect = GUICtrlCreateButton("Cancel", 256, 352, 73, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $cancelDefect exitloop Case $addDefect tabellog() local $log_testat[1][15] $log_testat[0][0] = Guictrlread($numeInput) $log_testat[0][1] = Guictrlread($dataInput) $log_testat[0][2] = Guictrlread($orainput) $log_testat[0][3] = guictrlread($seriainput) $log_Testat[0][4] = "False" $log_testat[0][5] = "--" $log_testat[0][6] = "--" $log_testat[0][7] = "--" $log_testat[0][8] = "--" $log_testat[0][9] = "--" $log_testat[0][10] = "--" $log_testat[0][11] = "--" $log_testat[0][12] = "TRUE" $log_testat[0][13] = GuiCtrlread($DefectInput) $log_testat[0][14] = Guictrlread($InformatiiDefect) ;_ArrayDisplay($log_testat) $rows = UBound($log_testat) - 1 $columns = UBound($log_testat, 2) -1 For $i = 0 To $rows $sLine = "" For $j = 0 To $columns $sLine &= $log_testat[$i][$j] & ";" Next FileWriteLine($output_file, StringTrimRight($sLine, 1)) Next EndSwitch WEnd GUISetState(@SW_ENABLE, $Emulators) GUIDelete($DefectForm) ;;Sfarsit defectbox ;Case $Mylogs ;; inceput pt mylogs EndSwitch WEnd ;;Sfarsit cod Emulator GUISetState(@SW_ENABLE, $Main) GUIDelete($Emulators) Case $Addnewusername GUISetState(@SW_DISABLE, $Main) ;; inceput newuserform $NewUser = GUICreate("New username", 209, 188, -1, -1) $newuserinput = GUICtrlCreateInput("", 8, 40, 185, 21) $newpassinput = GUICtrlCreateInput("", 8, 96, 185, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $Createnewuser = GUICtrlCreateButton("&OK", 14, 128, 75, 25, $BS_NOTIFY) $Cancelnewuser = GUICtrlCreateButton("&Cancel", 111, 128, 75, 25, $BS_NOTIFY) $EnterPassLabel = GUICtrlCreateLabel("Enter password", 8, 68, 77, 17, 0) $newusername = GUICtrlCreateLabel("Enter New Username", 8, 16, 105, 17) GUISetState(@SW_SHOW) $citescini=IniReadSectionNames("accounts.ini") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop case $cancelnewuser Exitloop case $createnewuser if ControlGetText("","",$newuserinput) = "" or ControlGetText("","",$newpassinput) = "" then msgbox(0,"Error", "Username/Password can't be blank") Else $Criptatuser = _StringEncrypt(1,Guictrlread($newuserinput),$criptarekey,$passlevel) If _ArrayFindAll($citescini,$Criptatuser) Then $Criptatpass = _StringEncrypt(1,Guictrlread($newpassinput),$Criptarekey,$passlevel) $a = IniWriteSection("accounts.ini",$criptatuser, "password = " & $criptatpass) MsgBox( 4096, "Succes", "Username successfully created") Tabelusername() local $log_testat[1][4] $log_testat[0][0] = _StringEncrypt(1,$loginn,$criptarekey,$passlevel) $log_testat[0][1] = _StringEncrypt(1,$x,$criptarekey,$passlevel) $log_testat[0][2] = _StringEncrypt(1,$Timp,$criptarekey,$passlevel) $log_testat[0][3] = _StringEncrypt(1,guictrlread($Newuserinput),$criptarekey,$passlevel) $rows = UBound($log_testat) - 1 $columns = UBound($log_testat, 2) -1 For $i = 0 To $rows $sLine = "" For $j = 0 To $columns $sLine &= $log_testat[$i][$j] & ";" Next FileWriteLine($output_file, StringTrimRight($sLine, 1)) Next Else MsgBox( 4096, "Username Found", "This username is allready in use") EndIf Endif EndSwitch WEnd GUISetState(@SW_ENABLE, $Main) GUIDelete($Newuser) ;;sfarsit newuser form Case $Logs ; inceput de main log (arata toate logurile decodate EndSwitch WEnd ;;Sfarsit main Else msgbox(0,"Error","Wrong Password/username") Endif Else msgbox(0,"Error","Wrong username/password") EndIf Endif case $exitLogIn Exit EndSwitch WEnd ;;Sfarsit de log in Func TabelLog() local $nume_array[1][15] $nume_array[0][0] = "Nume" $nume_array[0][1] = "Data" $nume_array[0][2] = "Ora" $nume_array[0][3] = "Seria Emulatorului" $nume_array[0][4] = "Reparat Box" $nume_array[0][5] = "Cauza Defect" $nume_array[0][6] = "Piesa Schimbata 1" $nume_array[0][7] = "Piesa Schimbata 2" $nume_array[0][8] = "Piesa Schimbata 3" $nume_array[0][9] = "Testat" $nume_array[0][10] = "Netestat" $nume_array[0][11] = "Informatii Repair" $nume_array[0][12] = "DefectBox" $nume_array[0][13] = "Defect" $nume_array[0][14] = "Informatii Defect" ;_ArrayDisplay($nume_array) $rows = UBound($nume_array) - 1 $columns = UBound($nume_array, 2) -1 For $i = 0 To $rows $sLine = "" For $j = 0 To $columns $sLine &= $nume_array[$i][$j] & ";" Next FileWriteLine($output_file, StringTrimRight($sLine, 1)) Next EndFunc Func TabelLog1() ; this is encripted tabel to write in the .csv file ;aici vom encripta si numele de mai jos $numecodat1 = _StringEncrypt(1,"Nume",$criptarekey,$passlevel) $numecodat2 = _StringEncrypt(1,"Data",$criptarekey,$passlevel) $numecodat3 = _StringEncrypt(1,"Ora",$criptarekey,$passlevel) $numecodat4 = _StringEncrypt(1,"Seria Emulatorului",$criptarekey,$passlevel) $numecodat5 = _StringEncrypt(1,"Reparatbox",$criptarekey,$passlevel) $numecodat6 = _StringEncrypt(1,"Cauza Defect",$criptarekey,$passlevel) $numecodat7 = _StringEncrypt(1,"Piesa Schimbata 1",$criptarekey,$passlevel) $numecodat8 = _StringEncrypt(1,"Piesa Schimbata 2",$criptarekey,$passlevel) $numecodat9 = _StringEncrypt(1,"Piesa Schimbata 3",$criptarekey,$passlevel) $numecodat10 = _StringEncrypt(1,"Testat",$criptarekey,$passlevel) $numecodat11 = _StringEncrypt(1,"Netestat",$criptarekey,$passlevel) $numecodat12 = _StringEncrypt(1,"Defectbox",$criptarekey,$passlevel) $numecodat13 = _StringEncrypt(1,"Defect",$criptarekey,$passlevel) $numecodat14 = _StringEncrypt(1,"Informatii Defect",$criptarekey,$passlevel) local $nume_array[1][14] $nume_array[0][0] = $numecodat1 $nume_array[0][1] = $numecodat2 $nume_array[0][2] = $numecodat3 $nume_array[0][3] = $numecodat4 $nume_array[0][4] = $numecodat5 $nume_array[0][5] = $numecodat6 $nume_array[0][6] = $numecodat7 $nume_array[0][7] = $numecodat8 $nume_array[0][8] = $numecodat9 $nume_array[0][9] = $numecodat10 $nume_array[0][10] = $numecodat11 $nume_array[0][11] = $numecodat12 $nume_array[0][12] = $numecodat13 $nume_array[0][13] = $numecodat14 _ArrayDisplay($nume_array) $rows = UBound($nume_array) - 1 $columns = UBound($nume_array, 2) -1 For $i = 0 To $rows $sLine = "" For $j = 0 To $columns $sLine &= $nume_array[$i][$j] & ";" Next FileWriteLine($output_file, StringTrimRight($sLine, 1)) Next EndFunc Func TabelUsername() local $nume_array[1][4] $nume_array[0][0] = "Creat de:" $nume_array[0][1] = "Data" $nume_array[0][2] = "Ora" $nume_array[0][3] = "Username Creat:" $rows = UBound($nume_array) - 1 $columns = UBound($nume_array, 2) -1 For $i = 0 To $rows $sLine = "" For $j = 0 To $columns $sLine &= $nume_array[$i][$j] & ";" Next FileWriteLine($output_file, StringTrimRight($sLine, 1)) Next EndFunc Link to comment Share on other sites More sharing options...
enaiman Posted May 12, 2011 Share Posted May 12, 2011 This will give you something to play with: Global $myCSV, $userArray[1000], $counter = 0 Global $username = "mircea" _FileReadToArray("my csv file", $myCSV) For $i = 1 To $myCSV[0] If StringLeft(StringStripWS($myCSV[$i], 1), StringLen($username)) = $username Then $userArray[$counter] = $myCSV[$i] $counter += 1 EndIf Next ReDim $userArray[$counter+1] _ArrayDisplay($userArray) You need to add includes, to use your filename, username ... What it does - it searches for "username" and put all the lines where that username is found in a new array. The code is not tested and it might need minor tweaks - but you have the idea now. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
mircea Posted May 13, 2011 Author Share Posted May 13, 2011 Thank you so much, yes now i got the ideea. I can't wait to get back from work and start working. I tested and hasn't any problem, too bad it dosen't put the informations in arrays but it's perfect. Link to comment Share on other sites More sharing options...
enaiman Posted May 13, 2011 Share Posted May 13, 2011 too bad it dosen't put the informations in arraysAll you need to do is: StringSplit every element of $userArray and you have your results. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
mircea Posted May 13, 2011 Author Share Posted May 13, 2011 After lot of searching on the forum, and my brother... the help file in a sort a way i trace out the problem. I used the Stringsplit how @enaiman recommend me but each time i press the log button it shows me the value 1 in the table. Could someone tell me were i did wrong? Thank you very much and specially to @enaiman who guide me and even told me how to do. P.S After i talked with @Taietel, and he's recomandation was to use Csv editor, i tried to use it but i had no luck, i wanted to use some functions so i included the file and after that each time i load the program it was loading me the CSV EDITOR Program. Global $myCSV, $userArray[1000], $counter = 0 Global $username = "mircea" _FileReadToArray($output_file, $myCSV) For $i = 1 To $myCSV[0] StringSplit($userarray,";") If StringLeft(StringStripWS($myCSV[$i], 1), StringLen($username)) = $username Then $userArray[$counter] = $myCSV[$i] $counter += 1 EndIf Next ReDim $userArray[$counter+1] $testing = StringSplit($userarray, ";") _ArrayDisplay($testing) Link to comment Share on other sites More sharing options...
enaiman Posted May 15, 2011 Share Posted May 15, 2011 Hi mircea, I don't know what is not working on your script - I have made a minimal change - invented a content for your ini file and put it into an array just to give an example. This script works and it will display even the separated values into a new array. What you have to keep in mind: keep the structure of your csv file constant: you have 6 values (or whatever) so you will have 6 on every line - empty values? then the line will be 5 commas ",,,,," #include <Array.au3> Global $myCSV[4]=[3,"mircea,7.41 p.m,new_account_1,2,1xwire,0001", "vasile,8.41 a.m,new_account_2,100,nothing,0001-0101", "mircea,10.41 p.m,new_account_100,1000,all,1000-2000"] Global $userArray[1000], $counter = 0 Global $username = "mircea" Global $splitArray[1000][100] ;_FileReadToArray("my csv file", $myCSV) For $i = 1 To $myCSV[0] If StringLeft(StringStripWS($myCSV[$i], 1), StringLen($username)) = $username Then $userArray[$counter] = $myCSV[$i] $counter += 1 EndIf Next If $counter = 0 Then MsgBox(16, "Error", "Username not found") Else ReDim $userArray[$counter] _ArrayDisplay($userArray) For $i=0 To UBound($userArray)-1 $temp = StringSplit($userArray[$i], ",") If $i = 0 Then ReDim $splitArray[UBound($userArray)][$temp[0]] For $j = 1 To $temp[0] $splitArray[$i][$j-1] = $temp[$j] Next Next _ArrayDisplay($splitArray) EndIf SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
mircea Posted May 16, 2011 Author Share Posted May 16, 2011 I want to thank too @taietel and @enaiman who helped me on my project, and i can say with all my heart that this project is not only mine is there project too for the help they provided me. Thank you very much. And i hope in the future to ask for your help in case i will have any problems. 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