DemonWareXT
Members-
Posts
10 -
Joined
-
Last visited
DemonWareXT's Achievements
Seeker (1/7)
0
Reputation
-
Remove Blank Lines in a file
DemonWareXT replied to DemonWareXT's topic in AutoIt General Help and Support
@M23 Now it works, you're an hero about the number problem, I think this only happened because there was some array size confusion, which now doesn't happen any more since the line removing works correctly now -
Remove Blank Lines in a file
DemonWareXT replied to DemonWareXT's topic in AutoIt General Help and Support
StringStripWS() is only used to strip of white spaces, so I don't think it would work -
Remove Blank Lines in a file
DemonWareXT replied to DemonWareXT's topic in AutoIt General Help and Support
@M23 I sent you the code where I implemented your first try which worked perfectly^^ either you implement your second version or I'll send the file again with error xD Edit: attached it again autoTag_V2.5.au3 -
Remove Blank Lines in a file
DemonWareXT replied to DemonWareXT's topic in AutoIt General Help and Support
@M23 just realised that xD Attached the script the list is built up like this: list.csv blablabla;blablabla autoTag_V2.5.au3 -
Remove Blank Lines in a file
DemonWareXT replied to DemonWareXT's topic in AutoIt General Help and Support
@M23 it doesn't leave the first line blank, it enters a number in there? well if you really wanna see my whole code xD (I did put your first code in there again tho) Edit: I hope you can read it, somehow the code shows up crazy on ma PC, so I atached the script too #include <GuiConstants.au3> #include <Array.au3> #include <file.au3> #include <ButtonConstants.au3> #include <GUIListBox.au3> ;include <GUIConstantsEx.au3> ;#include <WindowsConstants.au3> ;#Include <GuiScrollBars.au3> ;~ HotKeySet("^w", "tag") HotKeySet("^q", "lTag") HotKeySet("{ESC}", "errorH") ;;;;HotKeySet("{DEL}", "del") ;************************** ;Global Variables ;************************** $listFull = @ScriptDir & 'list.csv' ;$listShort = @ScriptDir & 'list short names.txt' ;$listWhole = @ScriptDir & 'people.csv' $error = 0 Do ;clean up the lists ;~ $read=FileRead($listFull) ;~ FileDelete($listFull) ;~ Do ;~ $read=StringReplace($read,@CRLF&@CRLF,@CRLF) ;~ Until @extended=0 ;~ FileWrite($listFull,$read) ;call function to clear blank lines in text clearBlank() ;************************** ;read array from text file ;************************** ;read the whole array Dim $Whole If Not _FileReadToArray($listFull,$Whole) Then MsgBox(4096,"Error", " Error reading Array error:" & @error) Exit EndIf ;sort the array _ArraySort($Whole) ;write array back to csv _FileWriteFromArray($listFull,$Whole, 1) ;For $i = 1 to UBound($Whole)-1 ;Next Dim $helper[2] = [0,0] Dim $PeopleFull[1] Dim $PeopleShort[1] For $i = 1 to UBound($Whole)-1 $helper = StringSplit($Whole[$i],';', 1) ReDim $PeopleFull[UBound($PeopleFull)+1] ReDim $PeopleShort[UBound($PeopleShort)+1] $PeopleFull[$i] = $helper[1] $PeopleShort[$i] = $helper[2] ;MsgBox(0,"",$helper[1]) ;MsgBox(0,"",$helper[2]) Next ;************************** ;Create the GUI ;************************** ;Do while loop so we can rebuild the GUI if need be. ;main GUI window $Form1 = GUICreate("Auswählen",570,550,192,114) ;some textlables to eplain whats going on GUICtrlCreateLabel("1. Select people, use shift and ctrl", 10, 480) GUICtrlCreateLabel("2. Go to G+ get cursor in input dialog", 10, 500) GUICtrlCreateLabel("3. CTRL+Q to start Tagging", 10, 520) ;Button that adds ponies to the list $add = GUICtrlCreateButton("Add", 350, 520,50) ;Input Box $Input1 = GUICtrlCreateInput("", 200, 520, 150, 25) ;some textlables to explain whats going on GUICtrlCreateLabel("| Fomrate like this: Name;Shortname", 200, 480) GUICtrlCreateLabel("| Use with caution", 200, 500) ;Button to delete people $del = GUICtrlCreateButton("Delete Selected", 400, 520) ; Create an array to hold the checkbox ControlIds - make it the same size as the $PeopleFull array ;Global $Person[UBound($PeopleFull)] ;Global $del[UBound($PeopleFull)] ;Some variables to count stuff $count = 0 $counter = 0 ;if retry = 1 the do while loop will end $retry = 1 ;List of people $ListPeople = GUICtrlCreateList("", 10, 10, 550, 450, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL)) ;$ListPeople = GUICtrlCreateList("", 10, 10, 300, 450, BitOR($GUI_SS_DEFAULT_LIST,$LBS_MULTIPLESEL)) For $i = 1 to UBound($PeopleFull)-1 GUICtrlSetData($ListPeople, $PeopleFull[$i]) Next ;************************** ;Create GUI Actions ;************************** ;Set the GUI to be shown GUISetState(@SW_SHOW) Do $msg = GUIGetMsg() Switch $msg Case $add If GUICtrlRead ($Input1) = "" Then MsgBox(0,'Niet','Please... Input!') Else add() EndIf Case $del del() EndSwitch Until $msg = $GUI_EVENT_CLOSE Until $retry=1 ;Functions ;~ Func tag() ;~ ;First sleep 5seconds so the user can place the cursor to the right place ;~ ;Sleep(4000) ;~ $error = 0 ;~ For $i = 1 to UBound($PeopleFull)-1 ;~ If $error = 1 Then ;~ ElseIf GuiCTRLRead ($Person[$i]) = $GUI_CHECKED Then ;~ ClipPut($PeopleFull[$i]) ;~ ;Send("{+}") ;~ Send("^v") ;~ Sleep(1000) ;~ Send("{ENTER}") ;~ Sleep(500) ;~ EndIf ;~ Next ;~ EndFunc Func lTag() $items = _GUICtrlListBox_GetSelItems($ListPeople) Opt("SendKeyDelay",40) For $i = 1 to UBound($items)-1 If $error = 1 Then Else $item = $items[$i]+1 Send("{+}"); Send($PeopleShort[$item]) Sleep(1000) Send("{ENTER}") Sleep(500) EndIf Next Opt("SendKeyDelay",5) Send("{CTRLUP}") ;Send("{SHIFTUP}") ;Send("{ALTUP}") $error = 0 EndFunc Func clearBlank() Global $aLines _FileReadToArray($listFull, $aLines) For $i = $aLines[0] To 1 Step -1 If $aLines[$i] = "" Then _ArrayDelete($aLines, $i) EndIf Next _FileWriteFromArray($listFull, $aLines, 1) EndFunc Func add() ;$counter = $counter ReDim $Whole[UBound($Whole)+1] $Whole[$counter] = GUICtrlRead ($Input1) _ArraySort($Whole) _FileWriteFromArray($listFull,$Whole, 1) $helper = StringSplit(GUICtrlRead ($Input1),';', 1) ReDim $PeopleFull[UBound($PeopleFull)+1] ReDim $PeopleShort[UBound($PeopleShort)+1] $PeopleFull[$i] = $helper[1] $PeopleShort[$i] = $helper[2] GUICtrlSetData($ListPeople, $helper[1]) _ArraySort($PeopleFull) _ArraySort($PeopleShort) EndFunc Func del() $items = _GUICtrlListBox_GetSelItems($ListPeople) For $i = 1 to UBound($items)-1 $item = $items[$i]+1 $PeopleFull[$item] = "" $PeopleShort[$item] = "" $Whole[$item] = "" ;MsgBox(0,"",$PeopleShort[1]) Next _ArraySort($PeopleFull) _ArraySort($PeopleShort) _ArraySort($Whole) _FileWriteFromArray($listFull,$Whole, 1) clearBlank() GUICtrlSetData($ListPeople, "") For $i = 1 to UBound($PeopleFull)-1 GUICtrlSetData($ListPeople, $PeopleFull[$i]) Next EndFunc ;debuging Func errorH() $error=1 ;Exit EndFunc The list behind it is called list.csv and is built up like this: name;name2 autoTag_V2.5.au3 -
Remove Blank Lines in a file
DemonWareXT replied to DemonWareXT's topic in AutoIt General Help and Support
@M23 your second version doesn't seem to work either, I get the original problem again, if there is a blank on the first line then it will crash... or maybe I'm to daft to implement it xD -
Remove Blank Lines in a file
DemonWareXT replied to DemonWareXT's topic in AutoIt General Help and Support
Thanks a lot M23 works like a charm -
Hey everyone, I'm back again with more problems ^^' I have an application that opens a file to read the stuff in there. What I want it to do beforehand is to remove blank lines from the File. Here is what I got $read=FileRead($listFull) FileDelete($listFull) Do $read=StringReplace($read,@CRLF&@CRLF,@CRLF) Until @extended=0 FileWrite($listFull,$read) It actually works quite well, but it runs into an error if the first line of the document is a blank line
-
Assign incremental Variables
DemonWareXT replied to DemonWareXT's topic in AutoIt General Help and Support
Melba23, you're a saviour! I did already try it with just $var[$i] which didn't work because I didn't know that I had to define it first Thanks a lot! -
First, hello everyone I'm not new to autoit but I'm quite the newb at GUI building, so far I only mad GUI-less stuff But alas the day has come, I finally ran into trouble with GUIs and here is ma problem: So what I am trying to do is build a GUI with an undefined number of checkboxes, I have an array in the background that should be used for that purpose. Now as I take it every checkbox needs to have a variable and I have no idea how I can make auto incremental variables. This is what I have $y = 10 $count = 0 For $i = 1 to UBound($People)-1 $Person = GUICtrlCreateCheckbox($People[$i], 24, $y) $y = $y + 25 $count = $count + 1 Next But like this the checkboxes are made but are not usable. Does anyone have an idea how to fix that? Or an alternative way to do this? Thank you very muuch :3