Jump to content

[Q] FTP_ListtoArray is not array!


Recommended Posts

I have got a customer script.And i use this script for controlling user id.When i use in scite editor and press F5, it isnt problem but when i compile script and run it, I take an error from this line: "for $F = 1 to $aFile[0]" and i found using vargettype($afile) this variable. $afile is a int32 variable.But it must be an array.__FTP_ListToArray give to @error.@error = 1 (in ftpex.au3 line 1351 "If @error Or Not $callFindFirst[0] Then Return SetError(1, _WinAPI_GetLastError(), 0)")

func _UyeAdiDurumu($okuma)
    Local $aFile, $F
    $aFile = __FTP_ListToArray($Conn, 2, 0, 0, 1, 0)
    if not @error Then
        if IsArray($aFile) Then
            for $F = 1 to $aFile[0]
                if StringRight($aFile[$F],4) = ".dat" Then
                    if $okuma = StringTrimRight($aFile[$F],4) Then
                        Return False
                    EndIf
                EndIf
            Next
            Return True
        Else
            MsgBox(16,"Hata!: 2","Giriş için gerekli veri FTP'den alınamadı.")
            _exit(1)
        EndIf
    Else
        MsgBox(16,"Hata!: 3"&@error&@extended,"Giriş için gerekli veri FTP'den alınamadı.")
        _exit(1)
    EndIf
EndFunc

And now,, my question! how can i solve this problem?

Link to comment
Share on other sites

my first question

Is your $conn failing therefor not populating the array?

I just had a look at the help file, is your __FTP_ListToArray a custom function because in the help it's _FTP_ListToArray. 1 less _ in the beginning and 2 less perameters.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

$Open = _FTP_Open('Kayit') 
$Conn = _FTP_Connect($Open, $server, $username, $pass, 0, 21) 
If @error Then  
MsgBox(16, "Hata: Bağlantı", "FTP ile bağlantı yapılamadı"&@CRLF&"Program kapatılacak!")     
_exit(1) 
EndIf 
_FTP_DirSetCurrent($Conn,"/www/uyeler/")

it's on top.and i try to global $conn and global $open.

This function (__FTP_ListToArray) isnt a custom func. its start line 1336 in ftpex.au3

in fact that _FTP_ListToArray function use this (__FTP_ListToArray) function.

Link to comment
Share on other sites

ok, you set $Conn

then do this

_FTP_DirSetCurrent($Conn,"/www/uyeler/")

wouldn't that be what you wanted to use in

__FTP_ListToArray?

$NewConn=_FTP_DirSetCurrent($Conn,"/www/uyeler/")

$aFile = __FTP_ListToArray($NewConn, 2, 0, 0, 1, 0)

However, if they are able and change directories, wouldn't this also make $NewConn an invalid location to get the file list from?

(I'm totaly guessing but it seems logical)

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

DirSetCurrent return to dir name only.So it isnt.

When i am in scite, $aFile = __FTP_ListToArray($Conn, 2, 0, 0, 1, 0) is working and i can see files ,that are in "uyeler", with _ArrayDisplay($aFile)

Meanwhile, sometimes compiled exe can work.But most of time, it doesnt work.

Link to comment
Share on other sites

Unfortunately, The Problem is continue.When i use

func _UyeAdiDurumu($okuma)  
Local $aFile, $F    
$aFile = __FTP_ListToArray($Conn, 2, 0, 0, 1, 0)    
;if not @error Then     
;if IsArray($aFile) Then 
    for $F = 1 to $aFile[0]                 
        if StringRight($aFile[$F],4) = ".dat" Then                  
            if $okuma = StringTrimRight($aFile[$F],4) Then                      
                Return False                    
            EndIf       
        EndIf
    Next
    Return True     
;Else   
;   MsgBox(16,"Hata!: 2","Giriş için gerekli veri FTP'den alınamadı.")  
;   _exit(1)    
;EndIf  
;Else   
;   MsgBox(16,"Hata!: 3"&@error&@extended,"Giriş için gerekli veri FTP'den alınamadı.")     
;   _exit(1)    
;EndIf 
EndFunc

this function. I take this error:

"Line 11989 (File "G:\server.exe"):"

Error: Subscript used with non-Array variable.

Line 11989: for $F = 1 to $aFile[0]

Edited by blackman12
Link to comment
Share on other sites

I think the problem lies in using both the set functions for the UDF (ones found in the helpfile) combined with the function inside the UDF written specifically to make the udf work.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

  • 1 month later...

The Problem is continue. i try another (basic script)* its work, but in my script it doesnt work.Meanwhile, i try it in scite its again work but when i compiled it, it doesnt work and give an error that is written on my previous messages.

i write a different way this script but it doesnt work.if you say, maybe i can solve it, if you want, i send to you all of sources.

func _UyeAdiDurumu($okuma)
    Local $h_Handle
    $aFile = _FTP_FindFileFirst($Conn, "/www/uyeler", $h_Handle,0x80000000)
    if @error = 0 Then
        while @error = 0
            if StringRight($aFile[10],4) = ".dat" Then
                if $okuma = StringTrimRight($aFile[10],4) Then
                    Return False
                EndIf
            EndIf
            $aFile = _FTP_FindFileNext($h_Handle)
        WEnd
        _FTP_FindFileClose($h_Handle)
        Return True
    ;Local $aFile, $F
    ;_FTP_DirSetCurrent($Conn,"/www/uyeler")
    ;$aFile = _FTP_ListToArray($Conn,2,0x00000800)
    ;if not @error Then
    ;   if IsArray($aFile) Then
    ;       for $F = 1 to $aFile[0]
    ;           if StringRight($aFile[$F],4) = ".dat" Then
    ;               if $okuma = StringTrimRight($aFile[$F],4) Then
    ;                   Return False
    ;               EndIf
    ;           EndIf
    ;       Next
    ;       Return True
    ;   Else
    ;       MsgBox(16,"Hata: ","Giriş için gerekli veri FTP'den alınamadı.")
    ;       _exit(1)
    ;   EndIf
    ;Else
    ;   MsgBox(16,"Hata: ","Giriş için gerekli veri FTP'den alınamadı.")
    ;   _exit(1)
    EndIf
EndFunc

* = basic script:

#include <FTPEx.au3>
$server = 'easyenglish.tc'
$username = 'easyenglish.tc'
$pass = "xxxxx"
$Open = _FTP_Open('Kayit')
$Conn = _FTP_Connect($Open, $server, $username, $pass)
If @error Then Exit
;_FTP_DirSetCurrent($Conn,"/www/uyeler/")
Local $h_Handle
$aFile = _FTP_FindFileFirst($Conn, "/www/uyeler/", $h_Handle)
if @error = 0 Then
    while @error = 0
        MsgBox(0,"a",$aFile[10])
        $aFile = _FTP_FindFileNext($h_Handle)
    WEnd
    MsgBox(0,"finish","finish")
EndIf
Edited by blackman12
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...