Jump to content
Sign in to follow this  
Imbuter2000

dim or local/global to declare an array

Recommended Posts

Imbuter2000

Some say that dim is deprecated and we should use local/global to declare variables... but I see that many(?) here in the forum still use dim to declare arrays. Is there a good reason for it?

Edited by Imbuter2000

Share this post


Link to post
Share on other sites
BrewManNH

Dim or ReDim? Dim is deprecated because it can cause too many issues in its implementation if not used correctly. Older code examples might be using Dim because it wasn't frowned upon to use it when they were written.


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

Share this post


Link to post
Share on other sites
Imbuter2000

Dim... not ReDim... I still use it in code in recent post in this forum...

Share this post


Link to post
Share on other sites
water

But Dim is still deprecated and hence shouldn't be used anymore. Deprecated features can be removed any time from AutoIt.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
BrewManNH

Dim... not ReDim... I still use it in code in recent post in this forum...

You're doing it wrong then, you need to stop.

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

Share this post


Link to post
Share on other sites
Imbuter2000

You're doing it wrong then, you need to stop.

"I still use it in code in recent post in this forum..." oopppsss, I wanted to write that I still SEE it in code in recent posts in this forum...

Ok then, got it, thanks for your advice!

Edited by Imbuter2000

Share this post


Link to post
Share on other sites
BrewManNH

"I still use it in code in recent post in this forum..." oopppsss, I wanted to write that I still SEE it in code in recent posts in this forum...

Ok then, got it, thanks for your advice!

I should have realized that you meant see instead of use.

If you're still seeing it in code then THEY'RE doing it wrong and they need to stop.

I understand that some people come here from VBScript, where Dim is practically the only declaration statement they know (and perhaps Set too if they use objects), but still this isn't VBScript, and someday the Dim command might go away completely.


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

Share this post


Link to post
Share on other sites
Mat

But Dim is still deprecated and hence shouldn't be used anymore. Deprecated features can be removed any time from AutoIt.

Don't think it's ever been deprecated.

I can't think of any scenario where it would be used though.

Share this post


Link to post
Share on other sites
BrewManNH

Don't think it's ever been deprecated.

Run Au3Check on this.

#AutoIt3Wrapper_AU3Check_Parameters=-w 6
Dim $test

It's been in there since at least 2006 as far as I can tell by searching the forums.


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

Share this post


Link to post
Share on other sites
Mat

Run Au3Check on this.

#AutoIt3Wrapper_AU3Check_Parameters=-w 6
Dim $test

It's been in there since at least 2006 as far as I can tell by searching the forums.

Nothing about it in the helpfile. Either it is meant to be deprecated and should be noted as such in the helpfile, or Au3Check needs to change its wording.

Share this post


Link to post
Share on other sites
czardas

oopppsss, I wanted to write that I still SEE it in code in recent posts in this forum...

That fooled me for quite a while too (though I've stopped using Dim now). Unfortunately I don't have anything to replace it with - other types of declaration are different - but never mind.

One of the things I like to do is use a variety of methods when coding, to expand my horizons, and what better way than by copying examples by experienced programmers. There's lots of Dim declarations on the forum. I don't know why it was depreciated really. It appears to have some unique, and potentially useful, properties.

is a good read. Read the follow up comments to that post. It will give you more of an idea what is going on with Dim. I still have some quandries regarding it, but there seems no point in pursuing them since the decision to depreciate Dim was made a while ago.

Edited by czardas

Share this post


Link to post
Share on other sites
BrewManNH

Rereading the change logs of AutoIt, it appears that Dim was changed back in 2003, to make AutoIt more compatible with VBScript code, so that it could be used to declare variables. I can't be sure, because there isn't a version prior to 3.0.100 in the archives, but it appears that Dim might have been meant to originally be used for declaring arrays.


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

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  

×