Jump to content

undeclared variable error. But variable is declared


martin
 Share

Recommended Posts

When I try to run a script I get the following error

>Running AU3Check (1.54.9.0) params: from:D:\Program Files\AutoIt3\beta

+>AU3Check ended.rc:0

>Running:(3.2.9.3): d:\Program Files\AutoIt3\beta\autoit3.exe "Q:\updater\MonItTemp.au3"

Q:\updater\MonItTemp.au3 (2475) : ==> Variable used without being declared.:

DllStructSetData($MonItStruct,$MILineNumber,Number($bb_line))

DllStructSetData(^ ERROR

->AutoIT3.exe ended.rc:1

>Exit code: 1 Time: 6.768

But the variable $MoniItStruct is used many times in the script and even several lines before line 2475 and no error is reported for those occurrences.

The variable $MonItStruct is declared as a Global variable near the beginning of the script.

Presumably autoit3.exe performs its own checks before executing the script because this error is given before the first line of the script is executed.(I inserted a consolewrite line at the strat to test this.)

Does anyone know if this could be related to the file size which is about 2500 lines?

I didn't have this problem when the file was smaller.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Should not matter.

Is the $MonItStruct variable used in an Adlib function or something ?

No, it is used in a fnction which is called often but well after the variable is declared.

But why do I get the error even before the script has started to run, i.e. before the first line is executed?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • Developers

No, it is used in a fnction which is called often but well after the variable is declared.

But why do I get the error even before the script has started to run, i.e. before the first line is executed?

AutoIt3 only gives the error when the specific line is performed... AU3check does the chekcing of the whole script.

That is the reason why I asked about Adlib or something because au3check will not be able to figure out if a func is preformed and contains variable that aren't declared yet.

Somehow this line is encountere before the variable is declared ...

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

AutoIt3 only gives the error when the specific line is performed... AU3check does the chekcing of the whole script.

That is the reason why I asked about Adlib or something because au3check will not be able to figure out if a func is preformed and contains variable that aren't declared yet.

Somehow this line is encountere before the variable is declared ...

Jos

This is the start of the script

ConsoleWrite('started' & @LF)

#include-once
#include <GUIConstants.au3>
#include <misc.au3>
#include 'D:\Program Files\AutoIt3\beta\Include\dllcallback.au3'
;Opt("MustDeclareVars",1);only for testing this script
;functions added to and called by debugged script
Const $BB_Variables = 30
Global $BBCommand_SingleStep, $BBcommand_stopAtLine, $BBCommand_continue, $BB_lineNum, $BB_functionName
Global $BBState_functionName, $bbState_halted

Global $MonItretval,$MonItpt,$MonIthStub_T,$MonItUpDatePeriod = 200,$MonItpnID1,$MonitStruct,$MonitLinked
MsgBox(0,'$MonitStruct declared','ok')

The Consolewrite on line1 doesn't get executed and nor does the msgbox after the Global vriable declaration so I assumed the script can't be running.

I have now also added a consolewrite line in the function where the problem is and that does get executed!

In that case how is the function called? Why is it called?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Is it declared global in a function or at the top of a script?

No it's a global variable declared as shown in my previous post, outside of any function.

EDIT: I should maybe add that the script itself is not expected to run because it needs another program to exist which it then communicates with. I am only trying to run it by itself it to find out why this error is reported. I get the same error when the supporting program is running though.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

No it's a global variable declared as shown in my previous post, outside of any function.

EDIT: I should maybe add that the script itself is not expected to run because it needs another program to exist which it then communicates with. I am only trying to run it by itself it to find out why this error is reported. I get the same error when the supporting program is running though.

I found the problem and it's obvious when you know. The script is a development for a debugger, and the script to debug is included in a wrapper script. The script I was debugging had a function onautoitstart and this code was being debugged before the debugger started working if you see what I mean.

Thanks for you attention Garry and Jos, apologies for wasting your time, I just couldn't understand it, but my debugger told me what was wrong with my debugger.

Debugging a debugger is a bugger.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

....

Debugging a debugger is a bugger.

That's why you (uhm, we) should not use GLOBAL variables. And invest some time in a simple Unit Test strategy..:)
Link to comment
Share on other sites

That's why you (uhm, we) should not use GLOBAL variables. And invest some time in a simple Unit Test strategy..:)

I know you're right, but for the way I'm trying to make a debugger I need global variables, unless you can tell me a good way to make a debugger without them, and which is fast.

Do you have a new baby Uten?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...