sree161 Posted October 28, 2017 Share Posted October 28, 2017 (edited) Hi, i have read a note pad and separated data in it using one seperater. i output is in array $s[1], $s[2], $s[3], $s[4], $s[5]....$s[12]. i want to send anyone of odd or even arrays to new notepad. can someone suggest some logic??? i am done till below code Quote $filePath = "C:\Users\ant\Desktop\afdsf.txt" Local $Input2 = FileRead($filePath) MsgBox(0,'input2',$Input2) $s = StringSplit($Input2 & "iretation" & @CRLF ,"iretation" & @CRLF, 1) ; $STR_ENTIRESPLIT (1) = entire delimiter string is needed to mark the split $iLRI = UBound($s) - 2 ; Last Array Index MsgBox(0,'iLRI',$iLRI) Local $sDisplay = "Output;" & @CRLF For $i = 1 To $s[0] Step 1 $sDisplay = "$s[" & $i & "]: " & $s[$i] & @CRLF MsgBox(0, "Results", $sDisplay) Next Edited October 28, 2017 by sree161 simply Link to comment Share on other sites More sharing options...
water Posted October 28, 2017 Share Posted October 28, 2017 If Mod($i, 2) = 0 Then ; process all even records here Else ; process all odd records here EndIf My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
czardas Posted October 28, 2017 Share Posted October 28, 2017 (edited) You can also use: For $i = 0 To Ubound($aArray) -1 Step 2 ; to process even elements: for odd elements start with $i = 1. You can also create two arrays using regular expressions. I'd have to double check the syntax. I think the suggestions made already are adequate. Edited October 28, 2017 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Malkey Posted October 29, 2017 Share Posted October 29, 2017 An example. Opt("WinTitleMatchMode", -2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase Local $Even Local $filePath = "C:\Users\ant\Desktop\afdsf.txt" ; "Gui.txt" ; Local $iretation = "" ; "iretation" ; Local $Input2 = FileRead($filePath) MsgBox(0, 'input2', $Input2) Local $a = StringSplit(StringStripCR($Input2), $iretation & @LF, 1) ; $STR_ENTIRESPLIT (1) = entire delimiter string is needed to mark the split While Sleep(100) $Even = InputBox("Testing", "Enter 1 for even, or" & @CRLF & " 0 for not even.", "", " M1") If @error Then Exit ; Cancel or top-right exit button pressed If $Even = "0" Or $Even = "1" Then ExitLoop Else MsgBox(0, "Error", 'Enter either a "1", or a "0" only', 2) EndIf WEnd Run("notepad.exe") WinWaitActive("Notepad") For $i = (1 + $Even) To UBound($a) - 1 Step 2 Send($a[$i] & @LF) Next 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