# Not Recognised Variables

## Recommended Posts

(Hello, the main problem is that X and Y are not given a value and I don't know why.)

Why do I get from the MsgBox(0, "X = " & \$pixelX, "Y = " & \$pixelY) answers    1, 1;    32, 1;    63, 1    instead of    44, 124;   74, 124;    104, 124;
I recognised that autoit doesn't realise that \$X and \$Y are given a value of 44 and 124;  no matter where I initialize them.

I did my tests where \$pixelY = \$Y (i just deleted {" + \$y*30 - 30"} from {"\$pixelY = \$Y + \$y*30 - 30"} and it gave me 1 as a result and then 1 incremented by 1 and so on.

Could you perhaps say what is amiss? I've done some projects already so I think I am not a complete beginner, but I've never experienced this kind of behaviour.

The code is here:

#include <Array.au3>
Global \$aArray[31][21]
Global \$x, \$y
Global \$X = 44, \$Y = 124
Global \$pixelX, \$pixelY
While 1
\$X = 44
\$Y = 124
For \$y = 1 To 20
\$pixelY = \$Y + \$y*30 - 30
For \$x = 1 To 30
\$pixelX = \$X + \$x*30 - 30
\$aArray[\$x][\$y] = PixelGetColor(\$pixelX, \$pixelY)
MsgBox(0, "X = " & \$pixelX, "Y = " & \$pixelY)

Next
Next
WEnd

##### Share on other sites
14 minutes ago, NedeljakM said:

Why﻿ do I get ﻿from the MsgBox(0, "X =﻿ " & \$pixelX, "Y = " & \$﻿pixelY﻿﻿) answers    1, 1;    32, ﻿1﻿;    63, ﻿1

Quote

Note that all variable names are case insensitive: MyVariable() is the same as MyvARiAblE()

Spoiler

##### Share on other sites

Thank you very much, I will not do the same mistake twice.

##### Share on other sites

Another thing to remember, you don't need to declare your loop variables before using them, they get automatically declared when you first use them in the loop. You can declare them, you just don't have to.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...