Sign in to follow this  
Followers 0
Armand

Func name($Delete = 0); $Delete is not declared ?!

18 posts in this topic

#1 ·  Posted (edited)

How could that be:

Func DownloadMoveToBOTTOM($Delete = 0)
    $Bottom = UBound($CurrentDownloadList) - 1
    $index = _GUICtrlListViewGetCurSel($DownloadList)
    If $index = $LV_ERR Or $index = $Bottom Then Return
    
    Dim $StorgeArray[1][14]
    For $i = 0 To 13
        $StorgeArray[0][$i] = $CurrentDownloadList[$index][$i]
    Next
    
    ;10|7 - 7=8, 8=9, 9=10
    For $i = $index + 1 To $Bottom
        ConsoleWrite("Moves: " & $i - 1 & "=" & $i & @CRLF)
        For $i2 = 0 To 13
            $CurrentDownloadList[$i - 1][$i2] = $CurrentDownloadList[$i][$i2]
        Next
    Next
    
    If $Delete = 0 Then
        For $i = 0 To 13
            $CurrentDownloadList[$Bottom][$i] = $StorgeArray[0][$i]
        Next
    Else
        ReDim $CurrentDownloadList[$Bottom][14]
    EndIf
    RefreshDownloadList($Bottom)
EndFunc   ;==>DownloadMoveToBOTTOM

i'm getting the bellow error:

C:\AU3 in progress\MakeInstallers.au3 (2322) : ==> Variable used without being declared.: 
If $Delete = 0 Then
If ^ ERROR

Anyone can explain me what am i doing wrong ?!

(P.S- mustdeclarevars is not set.)

Edited by Armand

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

I hate to ask the obvious... but are you using "If $Delete = 0 Then" anywhere else in the script?

Edit:

This worked fine for me:

_test()
Func _test($Delete = 0)
    If $Delete = 0 Then MsgBox(0,0,0)
EndFunc
Latest release. Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Are you using $Delete variable somewhere else in your script ?

The reason I ask is the function you posted shows: If $Delete = 0

The eroor code you have posted the error shows: If $Delete =0

Fing it hard to believe that the console write would alter the spacing of where it sees as an error..

Share this post


Link to post
Share on other sites

Noep... i wasn't mistaken, just ran a search and that line is no where but in that line the console reported the error at!

(the consol error was different since i manualy wrote it...)

also, that same thing works for me also in all of my other functions but in that certain func it keeps on giving me an error !!!

i've solved that issue using the following:

If IsDeclared("Delete") = 0 Then $Delete = 0

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Share this post


Link to post
Share on other sites

This shouldn't be happening. You've described an impossible situation, as $Delete is declared in the function definition. If you use $Delete within the function, it's been declared. If you use it outside of the function, then it will throw the error.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Try this and see if you still get the error;

Func DownloadMoveToBOTTOM()
    $Delete = 0
    $Bottom = UBound($CurrentDownloadList) - 1
...

And check which line the error is pointing at.

Scite will output the line the error is thrown without doing that.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

MY POINT EXACTLY !!!

i can't put my entire script here but if you want i can make a movie capturing the entire event !!!

anyhow - i solved it by using what i told you ... whithout that extra line it gives me the "Impossiable" Error described.

Edited by Armand

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Share this post


Link to post
Share on other sites

DIM $Delete

??


Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Share this post


Link to post
Share on other sites

I've just commented the above 'solution' line, ran the script till the error and took a screenpic:

Posted Image

this stacks up with my other Unexplained AU3 error of the 'filewrite' function...


[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Share this post


Link to post
Share on other sites

How are you calling this Func ? .... maybe using an EVENT Function ?

Jos

Ooh. Good question. This error looks hauntingly familiar:

HotKeySet("{ESC}", "_Quit")
HotKeySet("{HOME}", "DownloadMoveToBOTTOM")

While 1
    Sleep(20)
WEnd

Func DownloadMoveToBOTTOM($Delete = 0)
    If $Delete = 0 Then
        MsgBox(16, "Zero", "Zero")
    Else
        MsgBox(64, "Non-Zero", $Delete)
    EndIf
EndFunc   ;==>DownloadMoveToBOTTOM

Func _Quit()
    Exit
EndFunc   ;==>_Quit

Console output:

>"C:\Progra~1\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Temp\Test.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams    
+>12:18:18 Starting AutoIt3Wrapper v.1.9.3
>Running AU3Check (1.54.9.0)  from:C:\Program Files\AutoIt3
+>12:18:18 AU3Check ended.rc:0
>Running:(3.2.8.1):C:\Program Files\AutoIt3\autoit3.exe "C:\Temp\Test.au3"  
C:\Temp\Test.au3 (9) : ==> Variable used without being declared.: 
If $Delete = 0 Then 
If ^ ERROR
->12:18:21 AutoIT3.exe ended.rc:1
+>12:18:22 AutoIt3Wrapper Finished
>Exit code: 1   Time: 4.274

@Armand: As it says in the help file, you can't use functions with parameters for events. Not in HotKeySet, GuiSetOnEvent, or GuiCtrlSetOnEvent, etc.

:)


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

Share this post


Link to post
Share on other sites

but the variable is not sent through the 'EVENT' it is set by the function !!!

- anyhow, you are correct, the function is called by an event as my script is based 'OnEvent'.

Thanks and have a nice day !!!

P.S - either way it is solved with the line i've provided...

(maybe it should be written somewhere in the help file remarks...)


[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Share this post


Link to post
Share on other sites

maybe this is a good suggestion to add this in the helpfile.

I had the same problem and spend about 30 minutes looking for the error.

I just fixed it by creating another function and pointing the GuiCtrlSetOnEvent to the new function

Old code

GuiCtrlSetOnEvent ($btn_save, "_SettingsSave")

Func _SettingSave($msg = "")
   xxx
   If $msg <> "" Then MsgBox(0...)
EndFunc

New Code

GuiCtrlSetOnEvent ($btn_save, "_SettingsSaveSC")

Func _SettingsSaveSC()
   _SettingsSave()
EndFunc

Func _SettingsSave($msg = "")
xxx
   If $msg <> "" Then MsgBox(0...)
EndFunc

Share this post


Link to post
Share on other sites

I remember having this problem in older versions of AutoIt....

I solved the problem by using "Dim $variable" since Dim declares the variable as local only if it can.

The three downsides to using fixing the problem (more specifically, using Dim to fix it.):

1. You will receive Au3Check Warnings that $variable is already declared, ironically because you are fixing an undeclared error.

2. You will receive heavy criticization from people who see it as inefficient or see the Au3Check warnings, themselves.

3. $variable might be null.

-The upside is that it's the shorted fix.

On a related note:

Another peculiar problem I had with functions was "using local arrays under cpu load" where a local array inside a function wouldn't get declared

ex:

Func Function()
    Local $array[1]; imagine $array isn't defined elsewhere
    $array[0]="something"
EndFunc

which would usually end up returning one of three things:

-$array is a nonarray variable referenced as an array

-$array is undefined

-Expected a "=" operator in assignment statement.:

$array[0]="something"

$array^ ERROR

Bugs are always fun :|


My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
Share on other sites

I remember having this problem in older versions of AutoIt....

I solved the problem by using "Dim $variable" since Dim declares the variable as local only if it can.

The three downsides to using fixing the problem (more specifically, using Dim to fix it.):

1. You will receive Au3Check Warnings that $variable is already declared, ironically because you are fixing an undeclared error.

2. You will receive heavy criticization from people who see it as inefficient or see the Au3Check warnings, themselves.

3. $variable might be null.

-The upside is that it's the shorted fix.

On a related note:

Another peculiar problem I had with functions was "using local arrays under cpu load" where a local array inside a function wouldn't get declared

ex:

Func Function()
    Local $array[1]; imagine $array isn't defined elsewhere
    $array[0]="something"
EndFunc

which would usually end up returning one of three things:

-$array is a nonarray variable referenced as an array

-$array is undefined

-Expected a "=" operator in assignment statement.:

$array[0]="something"

$array^ ERROR

Bugs are always fun :|

What bugs?

Can you code something that reproduces your error for someone else to test?

:)


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

Share this post


Link to post
Share on other sites

Can you code something that reproduces your error for someone else to test?

I can't they've probably already been fixed.

See Here:

older versions of AutoIt


My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)

Share this post


Link to post
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
Sign in to follow this  
Followers 0