Jump to content

dynamically resizing arrays?


Recommended Posts

Hello all,

I've got some code, and I was wondering how I was supposed to manage this?

I get an error that $ret wasn't declared?

Here's a chunk of the code.

pcode=autoit]

$files=FileOpenDialog("file(s) to open?", _GetLastKnownDir(), "aiff(*.aiff)|wave(*.wav)|ogg vorbis(*.ogg)|flac(*.flac)|mp3(*.mp3)|mod(*.mod)|s3m(*.s3m)|it(*.it)|xm(*.xm)", 1+2+4)

if not IsString($files) then

return 0

EndIf

$parse=StringSplit($files, "|")

if ($parse[0]==1) then

$path=StringSplit($parse[1], "\")

$str=""

for $i = 1 to $path[0]-1

$str=$str&$path[$i]&"\"

next

_WriteLastKnownDir($str)

return

EndIf

_WriteLastKnownDir($parse[1])

for $counter = 2 to $parse[0]

$parse[$counter]=$parse[1]&"\"&$parse[$counter]

next

$counter=ubound($parse)-2

dim $ret[$counter]

$ret[0]=ubound($ret)-2

for $counter = 1 to $ret[0]

$ret[$counter]=_ArrayPop($parse)

next

return $ret --error is here.

EndFunc

~~TheCreator~~Visit http://tysdomain.com for personal software and website solutions.

Link to comment
Share on other sites

Hello all,

I've got some code, and I was wondering how I was supposed to manage this?

I get an error that $ret wasn't declared?

Here's a chunk of the code.

Well... you've got an EndFunc without a Func, which is kind of.... wait for it... funky!

GRROOOOOoooooan!

:whistle:

P.S. ...and, sure enough, $ret is not declared. We seem to be missing a lot of code here. :lmao:

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Well... you've got an EndFunc without a Func, which is kind of.... wait for it... funky!

GRROOOOOoooooan!

:whistle:

P.S. ...and, sure enough, $ret is not declared. We seem to be missing a lot of code here. :lmao:

-->

dim $ret[$counter]

Func X()
    $files=FileOpenDialog("file(s) to open?", "", "aiff(*.aiff)|wave(*.wav)|ogg vorbis(*.ogg)|flac(*.flac)|mp3(*.mp3)|mod(*.mod)|s3m(*.s3m)|it(*.it)|xm(*.xm)", 1+2+4)
    if not IsString($files) then
        return 0
    EndIf
    $parse=StringSplit($files, "|")
    if ($parse[0]==1) then
        $path=StringSplit($parse[1], "\")
        $str=""
        for $i = 1 to $path[0]-1
            $str=$str&$path[$i]&"\"
        next
    ;_WriteLastKnownDir($str)
        return
    EndIf
;_WriteLastKnownDir($parse[1])
    for $counter = 2 to $parse[0]
        $parse[$counter]=$parse[1]&"\"&$parse[$counter]
    next
    $counter=ubound($parse)-2
    dim $ret[$counter]
    $ret[0]=ubound($ret)-2
    for $counter = 1 to $ret[0]
        $ret[$counter]=_ArrayPop($parse)
    next
    return $ret; --error is here.
EndFunc

$hello = x()
_ArrayDisplay($hello)

Works for me. ;)

Edited by chris95219
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...