albertbatist Posted June 1, 2022 Share Posted June 1, 2022 I'm using the translator, because my English is terrible. I created a function to fetch files and copy to a location. The intention was to be able to copy several files where in inputox I would put a relationship separated by ";", but in the second copy it presents an error: Array variable has incorrect number of subscripts or subscript dimension range exceeded. Func : Link to comment Share on other sites More sharing options...
albertbatist Posted June 1, 2022 Author Share Posted June 1, 2022 Func _Copiar() ;MsgBox(64,"Teste","Recebendo click - MODO CÓPIA") $LendoRamal = GUICtrlRead($InputRamais) if $LendoRamal = "" Then Msgbox(16, "BUSCA LIGAÇOES DSA V.1.0", "Por favor insira um valor valido no campo ramal e tente novamente.",3) ;_Recarregar() Else $aRamais_Separados = StringSplit($lendoramal, ";", 1) ; separa cada ramal com ; For $i = 1 To $aRamais_Separados[0] ; Para cada ramal separado ;MsgBox(64,"Lendo Ramal", "Ramal atual que será procurado é: " & $aRamais_Separados[$i]) ;********************************************************** $pasta = GUICtrlRead($Drive) ; A pasta será o Drive lido (não há necessida de ficar copiando para várias variáveis, os dados que não serão modificados) $pasta &= "\" ; Acrescento um \ ;MsgBox(64,"Drive",$pasta) local $Filtro = "*_" & $aRamais_Separados[$i] & "_*" ; A cada loop, um novo ramal é armazenado em $Filtro e procurado msgbox("64", "DEBUG142", $filtro) ;Msgbox(64, "Teste", "Fazendo leitura do diretorio") Local $lista2 = _FileListToArrayRec($pasta, $Filtro, 1, 1, 1, 2) ; Procura em todas as pastas e subpasta e retorna seu caminho completo Local $resultado = _ArrayDisplay($lista2, "Lista de arquivos encontrados"); mostra o que foi encontrado num display msgbox("64", "DEBUG146", $resultado) Select Case @error = 1 MsgBox(16,"BUSCA LIGAÇOES DSA V.1.0", "Nenhum arquivo encontrado ou busca invalida.", 3) Case @error = 9 MsgBox(16,"BUSCA LIGAÇOES DSA V.1.0", "Nenhum arquivo encontrado ou busca invalida.", 3) Case Else msgbox("64", "DEBUG 158", $lista2[$i]) $LendoDestinoCopia = GUICtrlRead($InputDestino) DirCreate( $LendoDestinoCopia & "\" & $aRamais_Separados[$i]) $Destino = $LendoDestinoCopia & "\" & $aRamais_Separados[$i]& "\" msgbox("64", "DEBUG 157", $lista2[$i]) ;For $i = 1 To $lista2[0] ; Para cada arquivo encontrado local $Copia = FileCopy($lista2[$i], $Destino, 1) ; Copia todos o itens encontrados para o caminho especificado. Caso não seja especificado algum local ele copia para o direotorio raiz da maquina ; Exemplo C:\ ;MsgBox( 64, "Teste", $copia &"|" & $lista2[$i] & "|Destino: " & $Destino) FileWriteLine($Destino & "\LogCopia.log", $lista2[$i]) ;Escreve um log dentro do diretorio que ele criou com nome do ramal. SplashTextOn("Busca Ligações DSA V.1.0", "Copiando arquivos, favor aguardar...",480, 40, -1, -1, 1, "Verdana") ;SplashTextOn("Busca Ligações DSA V.1.0", "Copiando arquivos, favor aguardar...", -1, -1, -1, -1, 4, "", 24) Sleep(100) Link to comment Share on other sites More sharing options...
Subz Posted June 1, 2022 Share Posted June 1, 2022 Can you post your full code using the < > GuiCtrlRead implies you have a gui also, which isn't included in the code above. 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