Jump to content

Recommended Posts

Posted

Hello all! 

 

Getting this error :

(22) : ==> Variable used without being declared.:
if $vNumber = 0 Then
if ^ ERROR

 

But I'm sure I have defined the variable, as in the top of my script has 

Global $vNumber = 0

 

How would I go about fixing this?

 

Posted (edited)

Oh, I think I have figured it out. I no longer get an error any more when I put 

Global $vNumber

In the beginning of each of my functions

Edited by adjist
Posted

That sounds very wrong if it’s global it’s scope is global to the entire program and you shouldn’t have to declare it more than once

My resources are limited. You must ask the right questions

 

Posted
22 minutes ago, Earthshine said:

That sounds very wrong if it’s global it’s scope is global to the entire program and you shouldn’t have to declare it more than once

erm.. forget I said that

 

here is what I said on another post, this is pretty much what I am wanting to do

19 minutes ago, adjist said:

I see,

So you're saying , set something such as ?

Global $example = 0

At the top of my script, and inside the func I put ?

Func example()
$example = 1

;code

$example = 0
EndFunc

But when I do this, I get this error,

Variable used without being declared.

 

 

Posted

Didn't you try to run such a snippet?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted

Yes you can!

RTFM and see that's precisely the purpose of Global.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted
1 minute ago, jchd said:

Yes you can!

RTFM and see that's precisely the purpose of Global.

Sorry, I meant that I guess that functions cannot update variables while they are inside a loop

Posted

Wrong guess again.
What makes you believe that?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted
Just now, jchd said:

Wrong guess again.
What makes you believe that?

Well, if I try to change a variable in a loop such as

Func yea()
    While(1)
        $test = 1
        ;code
        $test = 0
    WEnd
EndFunc

and have an if statement (inside another function) such as 

func example()
    if $test = 1 Then
        ConsoleWrite("hello")
    EndIf
EndFunc

It won't print the message

If there is a way to do it, could you be able to tell me how?

Posted
1 minute ago, adjist said:

It won't print the message

No need to try to run the code, it's obvious the message can't be printed.

Beside the fact that the present code will never exit the function yea() since it contains an infinite loop without exit route, you reset $test to 0 before invoking example(), so no wonder the msg never prints.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted

Runable code:

Global $test = 0

yea()
example()

Func yea()
    Local $t = TimerInit()
    Do
        $test += 1
    Until TimerDiff($t) > 1000
EndFunc

func example()
    if $test > 0 Then
        ConsoleWrite("$test is now " & $test & @LF)
    EndIf
EndFunc

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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
×
×
  • Create New...