Romm Posted September 26, 2009 Share Posted September 26, 2009 I have ID.txt wich looks something like that:12345665432435545321343213213755465645677542423436577575I want to make something like _ArrayPop (Returns the last element of an array, deleting that element from the array at the same time.) but with the numbers from .txt file.Is this possible?If not, any other ideas?Thanks. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 26, 2009 Moderators Share Posted September 26, 2009 Romm,Perhaps if you tried scripting a short UDF which used _FileReadToArray to get the contents of ID.txt into an array, then used _ArrayPop to do what you want to do with the array, and then finally used _FileWriteToArray to replace ID.txt?Does not sound too difficult. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Malkey Posted September 26, 2009 Share Posted September 26, 2009 (edited) I have ID.txt wich looks something like that: I want to make something like _ArrayPop (Returns the last element of an array, deleting that element from the array at the same time.) but with the numbers from .txt file. Is this possible? If not, any other ideas? Thanks. The Regular Expressions for this _StringPop() were copied from here. ; ;http://www.autoitscript.com/forum/index.php?showtopic=103039&view=findpost&p=730555 ;Ref: http://www.autoitscript.com/forum/index.php?showtopic=101594&view=findpost&p=722113 Local $sStr = "12" & @CRLF & "34" & @CRLF & "56" & @CRLF & "7" & @CRLF & "89" & @CRLF & "10" & _ @CRLF & "11" & @CRLF & "13" & @CRLF & "14" & @CRLF & "15" & @CRLF & "16" & @CRLF & "99" & @CRLF Local $sResult = _StringPop($sStr) ;or ;Local $sResult = _StringPop(FileRead("FileName.txt")) MsgBox(0, '_Delete right', "From: " & @CRLF & $sStr & @CRLF & @CRLF & "Delete right" & @CRLF & " Result: " & @CRLF & $sResult) ;$hFile = FileOpen("FileName.txt", 2) ;FileWrite($hFile, $sStr) ;FileClose($hFile) Func _StringPop(ByRef $sString) Local $sTemp = StringRegExpReplace($sString, "(?:.*\v+)*(.+?)\v+$", "\1"); Retrieve right most entry or bottom line contexts. $sString = StringRegExpReplace($sString, "(?s)(.*\v+)*(.+\v+)\Z$", "\1") ; Delete right Return $sTemp EndFunc ;==>_StringPop ; Edit: Re-posted code. I just realized $" automatically changed to {:content:}quot; Edited September 27, 2009 by Malkey 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