Sign in to follow this  
Followers 0
Romm

Cut line from file...

3 posts in this topic

I have ID.txt wich looks something like that:

123456

65432435

545321343

213213

75546564

567754

242343

6577575

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.

Share this post


Link to post
Share on other sites



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. :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by Malkey

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0