AlmarM Posted April 21, 2009 Share Posted April 21, 2009 (edited) Hi,I'm busy on a program to read a certain file.expandcollapse popupGlobal Const $ES_READONLY = 0x0800 Global $FileOpen, $i = 2 Global $ID, $Name, $FM, $V, $X $GUI = GUICreate("FM Mobs Reader", 245, 130) $File = GUICtrlCreateInput("", 10, 10, 200, 20) $_select = GUICtrlCreateButton("...", 215, 10, 20, 20) $Progress = GUICtrlCreateProgress(10, 40, 225, 20) $ID = GUICtrlCreateInput("<ID>", 10, 70, 63, 20, $ES_READONLY) $Name = GUICtrlCreateInput("<Name>", 80, 70, 155, 20, $ES_READONLY) $FM = GUICtrlCreateInput("<FM>", 10, 100, 35, 20, $ES_READONLY) $V = GUICtrlCreateInput("<V>", 50, 100, 35, 20, $ES_READONLY) $X = GUICtrlCreateInput("<X>", 90, 100, 35, 20, $ES_READONLY) $Prev = GUICtrlCreateButton("Prev", 130, 100, 50, 20) $Next = GUICtrlCreateButton("Next", 185, 100, 50, 20) GUISetState() GUICtrlSetTip($ID, "Monster ID") GUICtrlSetTip($Name, "Monster Name") GUICtrlSetTip($FM, "FM Number") GUICtrlSetTip($V, "FM Floor") GUICtrlSetTip($X, "Times to be spawned") GUICtrlSetLimit($Progress, 100, 0) While 1 $nMsg = GUIGetMsg() Select Case $nMsg = -3 Exit Case $nMsg = $_select $_Temp_Read = GUICtrlRead($File) $fod = FileOpenDialog("Select Files", @DesktopDir, "Text Files (*.txt)", 3, "", $GUI) If @error Then GUICtrlSetData($File, $_Temp_Read) Else GUICtrlSetData($File, $fod) $FileOpen = FileOpen($fod, 0) GUICtrlSetData($Progress, 100) $i = 2 _GetData($FileOpen, $i) EndIf Case $nMsg = $Prev $i -= 1 _GetData($FileOpen, $i) Case $nMsg = $Next $i += 1 _GetData($FileOpen, $i) EndSelect WEnd Func _GetData($sPath, $sNum) $FileReadLine = FileReadLine($sPath, $sNum) $Split = StringSplit($FileReadLine, " ") GUICtrlSetData($ID, $Split[1]) GUICtrlSetData($Name, $Split[3]) GUICtrlSetData($FM, $Split[5]) GUICtrlSetData($V, $Split[6]) GUICtrlSetData($X, $Split[7]) EndFunc Func OnAutoItExit() FileClose($FileOpen) EndFuncFile contains:http://www.mediafire.com/?dz5jgrznjyuI need a way to split it.Try to see yourself.AlmarM Edited April 21, 2009 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Marlo Posted April 21, 2009 Share Posted April 21, 2009 I know that RegExp would help a hell of a lot here but unfortuneately i know jack sh*t about regexp =( Click here for the best AutoIt help possible.Currently Working on: Autoit RAT Link to comment Share on other sites More sharing options...
AlmarM Posted April 21, 2009 Author Share Posted April 21, 2009 (edited) I dont know if you saw the file but I uploaded it, take a look. AlmarM EDIT: I tried spliting it by the tabs " " but not every line has the same amount of tabs. Edited April 21, 2009 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
martin Posted April 21, 2009 Share Posted April 21, 2009 I dont know if you saw the file but I uploaded it, take a look. AlmarM EDIT: I tried spliting it by the tabs " " but not every line has the same amount of tabs. Try Func _GetData($sPath, $sNum) $FileReadLine = FileReadLine($sPath, $sNum) $Split = StringSplit(StringStripWS(StringReplace($FileReadLine,Chr(9)," "),4), " ") if UBound($Split) < 8 then ReDim $Split[8] GUICtrlSetData($ID, $Split[1]) GUICtrlSetData($Name, $Split[3]) GUICtrlSetData($FM, $Split[5]) GUICtrlSetData($V, $Split[6]) GUICtrlSetData($X, $Split[7]) EndFunc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
AlmarM Posted April 21, 2009 Author Share Posted April 21, 2009 (edited) Try Func _GetData($sPath, $sNum) $FileReadLine = FileReadLine($sPath, $sNum) $Split = StringSplit(StringStripWS(StringReplace($FileReadLine,Chr(9)," "),4), " ") if UBound($Split) < 8 then ReDim $Split[8] GUICtrlSetData($ID, $Split[1]) GUICtrlSetData($Name, $Split[3]) GUICtrlSetData($FM, $Split[5]) GUICtrlSetData($V, $Split[6]) GUICtrlSetData($X, $Split[7]) EndFuncHmmm, almost. But as I already said, not every line has the same amount of tabs! So the $Split[x] will be different for some lines. AlmarM EDIT: I figured out: Between ID and Name are always 2 tabs. Between Name and FM are 2 of 3 tabs. Between FM and V is always 1 tab. Between V and X is always 1 tab. EDIT: I found out: FM could be $Split[4], $Split[5] or $Split[6] Edited April 21, 2009 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
martin Posted April 21, 2009 Share Posted April 21, 2009 Hmmm, almost. But as I already said, not every line has the same amount of tabs! So the $Split[x] will be different for some lines. AlmarM EDIT: I figured out: Between ID and Name are always 2 tabs. Between Name and FM are 2 of 3 tabs. Between FM and V is always 1 tab. Between V and X is always 1 tab. EDIT: I found out: FM could be $Split[4], $Split[5] or $Split[6]Then there is something wrong with what I posted. StringReplace($FileReadLine,Chr(9)," ") is to replace every tab with a space StringStripWS(StringReplace($FileReadLine,Chr(9)," "),4) is to replace any spaces (1 or more) with just one space, so TAB SPACE SPACE SPACE TAB TAB would be reduced to SPACE and then the stringsplit will not be affected by tabs or multiple spaces. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Danny35d Posted April 21, 2009 Share Posted April 21, 2009 Func _GetData($sPath, $sNum) Local $iCount = 0 Dim $aCtrlID[5] = [$ID, $Name, $FM, $V, $X] $FileReadLine = FileReadLine($sPath, $sNum) $Split = StringSplit($FileReadLine, @TAB) For $x = 1 To $Split[0] If $Split[$x] <> '' Then GUICtrlSetData($aCtrlID[$iCount], $Split[$x]) $iCount += 1 EndIf Next EndFunc AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
AlmarM Posted April 21, 2009 Author Share Posted April 21, 2009 Func _GetData($sPath, $sNum) Local $iCount = 0 Dim $aCtrlID[5] = [$ID, $Name, $FM, $V, $X] $FileReadLine = FileReadLine($sPath, $sNum) $Split = StringSplit($FileReadLine, @TAB) For $x = 1 To $Split[0] If $Split[$x] <> '' Then GUICtrlSetData($aCtrlID[$iCount], $Split[$x]) $iCount += 1 EndIf Next EndFuncThankies Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. 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