rfedun Posted September 4, 2020 Share Posted September 4, 2020 Hi, I'm new to autoit and I just need some help removing a pipe character at the end of my output for my function. Essentially I need a pipe character at the end of each day of the week except Sunday. If you guys could help me here, I would really appreciate it. Local $days = StringSplit("Sunday,Monday,Tuesday,Wedneday,Thursday,Frday,Saturday", ",") ;$days[1] contains "Sun" ... $days[7] contains "Sat" Local $text = "This\nline\ncontains\nC-style breaks." Local $array = StringSplit($text, '\n', 1) Local $sRecieved = "doc no.:" Local $sPipe = "|" For $i = 1 to $days[0] $sRecieved = $sRecieved & " " & $days[$i] & $sPipe $sRecieved = StringLeft($sRecieved, StringReplace($sPipe, $days - 1, " ")) ; ConsoleWrite($sRecieved & StringLen($sRecieved) + $days[$i+1] + 1 & @CRLF) If $i < $days[0] Then If StringLen($sRecieved) < 20 and StringLen($sRecieved) + StringLen($days[$i+1]) + 1 > 20 Then ; If Len($sLink) < 2047 and Len($sLink) + Len($aDocuments) + 1 > 2047 Then MsgBox(0, "Days character length", $sRecieved) $sRecieved = "doc no.:" ; _ArrayDisplay($days) EndIf Else MsgBox(0, "Days character length", $sRecieved) EndIf Next Link to comment Share on other sites More sharing options...
Dan_555 Posted September 4, 2020 Share Posted September 4, 2020 (edited) This should do it: If $days[$i] = "Sunday" Then $sPipe = "" Else $sPipe = "|" EndIf insert it just after For $i = 1 To $days[0] Edited September 4, 2020 by Dan_555 Some of my script sourcecode Link to comment Share on other sites More sharing options...
Subz Posted September 4, 2020 Share Posted September 4, 2020 Didn't really understand what your output should look like as the code above returned nothing for me, you could use a ternary operator to create the string, for example: #include <Array.au3> Local $aDays = StringSplit("Sunday,Monday,Tuesday,Wedneday,Thursday,Frday,Saturday", ",") Local $sRecieved = "doc no.:" Local $sPipe = "|" For $i = 1 to $aDays[0] $sRecieved &= $i = 1 ? " " & $aDays[$i] : " " & $aDays[$i] & $sPipe ConsoleWrite($sRecieved & " - " & StringLen($sRecieved) & @CRLF) If StringLen($sRecieved) < 20 and StringLen($sRecieved) + (StringLen($aDays[$i]) + 1) > 20 Then MsgBox(0, "Days character length", $sRecieved) If $i = $aDays[0] Then MsgBox(0, "Days character length", $sRecieved) Next Link to comment Share on other sites More sharing options...
rfedun Posted September 4, 2020 Author Share Posted September 4, 2020 Quote Thanks guys 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