Cant Figure Out How To Combine Variables Extracted From An Array

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
roonyrooxcess
Posts: 61
Joined: 20 Nov 2020, 21:29

Cant Figure Out How To Combine Variables Extracted From An Array

19 Nov 2021, 12:45

Hi,

Im trying to remove all words containing UP & Down in an array, but i cant get the results to combine into a new variable ...

So basically remove any words with up ie 'ETHUPUSDT' or down from the array, & then copy the processed array to the clipboard

Thanks!

Code: Select all

#SingleInstance, force


string := "DOWN"

Clipboard = 

(

'BTCUSDT','XRPDOWNUSDT','MANAUSDT','ETHUPUSDT','BUSDUSDT','GALAUSDT','SUPERUSDT','SHIBUSDT','SOLUSDT'


)

tempArray := StrSplit(RegExReplace(Clipboard,","," "), " ")



;MsgBox % tempArray[1]

x:=10000
xl:=0
Loop, %x%
{
xl++
xs := tempArray[xl]
;msgbox %xs%
If InStr(xs, string)
{
xs:=xl
;MsgBox % "linenumber=" xs " "  tempArray[xs]

tempArray[xs]:=""

AddVar:= AddVar . tempArray[xs]

}

AddVar= % AddVar . tempArray[xs]

;MsgBox % AddVar 

}

Clipboard:=AddVar

MsgBox % Clipboard
return


User avatar
sharonhuston
Posts: 15
Joined: 15 Nov 2019, 10:51

Re: Cant Figure Out How To Combine Variables Extracted From An Array

19 Nov 2021, 13:20

NEVERMIND. This removes the word "UP" and "DOWN" but you want the element removed. You can't do this within an array loop because the array would resize while you work on it.

Maybe loop through the array . . .

Code: Select all

#SingleInstance, force

Clipboard := "" 

myArray := []
myArray.Push("BTCUSDT","XRPDOWNUSDT","MANAUSDT","ETHUPUSDT","BUSDUSDT","GALAUSDT","SUPERUSDT","SHIBUSDT","SOLUSDT")

Loop, % myArray.Length()
{
	pos := RegExReplace(myArray[A_Index], "UP", "")
	pos := RegExReplace(myArray[A_Index], "DOWN", "")
	Clipboard := Clipboard . " " . myArray[A_Index]
}


MsgBox %Clipboard%
Last edited by sharonhuston on 19 Nov 2021, 13:32, edited 1 time in total.
sofista
Posts: 654
Joined: 24 Feb 2020, 13:59
Location: Buenos Aires

Re: Cant Figure Out How To Combine Variables Extracted From An Array

19 Nov 2021, 13:27

Not sure, but maybe this is what you want:

Code: Select all

Clipboard = 
(
'BTCUSDT','XRPDOWNUSDT','MANAUSDT','ETHUPUSDT','BUSDUSDT','GALAUSDT','SUPERUSDT','SHIBUSDT','SOLUSDT'
)

tempArray := StrSplit(Clipboard,",")
myArray := []
myList := ""

For each, word in StrSplit(Clipboard, ",") {
	if !(InStr(word, "UP") || InStr(word, "DOWN")) {
		myArray.Push(word)
		myList .= word "`n"    ; just to visualice the content of myArray
	}
}

MsgBox, % myList
return

/* myList:

'BTCUSDT'
'MANAUSDT'
'BUSDUSDT'
'GALAUSDT'
'SHIBUSDT'
'SOLUSDT'

 */

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, Descolada, GroggyOtter, Mateusz53, moltenchees and 166 guests