youtuber Posted September 30, 2018 Posted September 30, 2018 (edited) Friends, I work with just one of them in Editbox. with $Data[$i], I want to read and edit it later with _MakeArrayUnique() But unfortunately both data are written Spoiler expandcollapse popup#include <Array.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 400, 338) $Edit1 = GUICtrlCreateEdit("", 24, 32, 350, 250) $Button1 = GUICtrlCreateButton("Button1", 150, 300, 65, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $Get = _HttpGetRegexTest("https://autoitscripttr.blogspot.com/atom.xml?redirect=false&start-index=1&max-results=500") $Data = StringRegExp($Get, '(https?[^;"]+)(?=(?:"|")[\w=\h"]*rel=(?:"|")?nofollow)', 3) If IsArray($Data) Then For $i = 0 To UBound($Data) - 1 GUICtrlSetData($Edit1, $Data[$i] & @CRLF, 1) Next EndIf _MakeArrayUnique() EndSwitch WEnd Func _MakeArrayUnique() $aArrayedit = StringSplit(StringStripCR(GUICtrlRead($Edit1)), @LF, 2) $aUnique = _ArrayUnique($aArrayedit) _ArraySort($aUnique, 0, 1) For $i = 1 To $aUnique[0] GUICtrlSetData($Edit1, $aUnique[$i] & @CRLF, 1) Next EndFunc Func _HttpGetRegexTest($aUrl) Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", $aUrl, False) $oHTTP.Send() If @error Then $error = 1 $oHTTP = 0 Return SetError(1) EndIf If $oHTTP.Status = 200 Then Local $sReceived = $oHTTP.ResponseText $oHTTP = Null Return $sReceived EndIf $oHTTP = Null Return -1 EndFunc Edited September 30, 2018 by youtuber
FrancescoDiMuro Posted September 30, 2018 Posted September 30, 2018 @youtuber What's the question? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Subz Posted September 30, 2018 Posted September 30, 2018 Why write the array to the Editbox when you are going to rewrite it in _MakeArrayUnique, you could use something like: expandcollapse popup#include <Array.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 400, 338) $Edit1 = GUICtrlCreateEdit("", 24, 32, 350, 250) $Button1 = GUICtrlCreateButton("Button1", 150, 300, 65, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $Get = _HttpGetRegexTest("https://autoitscripttr.blogspot.com/atom.xml?redirect=false&start-index=1&max-results=500") $aData = StringRegExp($Get, '(https?[^;"]+)(?=(?:"|")[\w=\h"]*rel=(?:"|")?nofollow)', 3) If IsArray($aData) Then _MakeArrayUnique($aData) EndSwitch WEnd Func _MakeArrayUnique($_aData) $aUnique = _ArrayUnique($_aData) _ArraySort($aUnique, 0, 1) For $i = 1 To $aUnique[0] GUICtrlSetData($Edit1, $aUnique[$i] & @CRLF, 1) Next EndFunc Func _HttpGetRegexTest($aUrl) Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", $aUrl, False) $oHTTP.Send() If @error Then $error = 1 $oHTTP = 0 Return SetError(1) EndIf If $oHTTP.Status = 200 Then Local $sReceived = $oHTTP.ResponseText $oHTTP = Null Return $sReceived EndIf $oHTTP = Null Return -1 EndFunc
youtuber Posted October 1, 2018 Author Posted October 1, 2018 @Subz I wonder if I could write back. Is something like this possible? Once the data has been retrieved from the etidbox, read it and then delete and replace the similar ones?
FrancescoDiMuro Posted October 1, 2018 Posted October 1, 2018 23 minutes ago, youtuber said: Once the data has been retrieved from the etidbox, read it and then delete and replace the similar ones? Yes, you can do it, but when you use GUICtrlSetData() to make the replace, you don't have to specify the last parameter of the function: default [optional] Combo, List: The default value. Edit, Input: If non-empty (""), the string is inserted at the current insertion point (caret). since, if it is used, you are going to append the text in the Edit control; else, you are going to overwrite it :) Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
youtuber Posted October 1, 2018 Author Posted October 1, 2018 should i do this Func _MakeArrayUnique() $aArrayedit = StringSplit(StringStripCR(GUICtrlRead($Edit1)), @LF, 2) $aUnique = _ArrayUnique($aArrayedit) _ArraySort($aUnique, 0, 1) For $i = 1 To $aUnique[0] GUICtrlSetData($Edit1, "") GUICtrlSetData($Edit1, $aUnique[$i] & @CRLF, 1) Next EndFunc
FrancescoDiMuro Posted October 1, 2018 Posted October 1, 2018 @youtuber No, since you are going to set "" and the $aUnique element for each element of the array, in your Edit control. Try this: Func _MakeArrayUnique() $aArrayedit = StringSplit(StringStripCR(GUICtrlRead($Edit1)), @LF, 2) $aUnique = _ArrayUnique($aArrayedit) _ArraySort($aUnique, 0, 1) GUICtrlSetData($Edit1, "") For $i = 1 To $aUnique[0] GUICtrlSetData($Edit1, $aUnique[$i] & @CRLF, 1) Next EndFunc youtuber 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
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