Sign in to follow this  
Followers 0
Xenobiologist

Why is there still the keyword dim?

11 posts in this topic

#1 ·  Posted (edited)

Hi,

I know that this has been discussed a while back, but I still do not understand.

Why do I need Dim?

Isn't local and global enough?

Thanks!

So long,

Mega

Edit: The reason why I'm asking is, cause we are currently writing a German tutorial for Autoit and I'd like to use to explain it. ;)

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites



http://www.autoitscript.com/forum/index.ph...st&p=230205

Maybe that's the discussion you mentioned.. I think Valik made it really clear there.

Hi, yeah I knew the thread and now my question is why not tidy up the language and delete dim and make a func like VarToArray or something.

That would make it more clear and easier, I guess (although it is not difficult)

But having scripts in the helpfile with DIM and scripts in the forum mixed local, global and Dim while not understandng the point behind it isn't good. IMO!

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi, yeah I knew the thread and now my question is why not tidy up the language and delete dim and make a func like VarToArray or something.

That would make it more clear and easier, I guess (although it is not difficult)

But having scripts in the helpfile with DIM and scripts in the forum mixed local, global and Dim while not understandng the point behind it isn't good. IMO!

So long,

Mega

Since I use Dim frequently and the less typing I have to do the better, perhaps you could explain a couple of things;

1) Why would I ever want to type VarToArray $A [0][0] When Dim $A[0][0] is faster?

2) Concerning your tutorial, what is the difference whether you explain the use of Dim or explain the use of VarToArray?

Edit

Forgot to mention that Dim is used in several languages.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Since I use Dim frequently and the less typing I have to do the better, perhaps you could explain a couple of things;

1) Why would I ever want to type VarToArray $A [0][0] When Dim $A[0][0] is faster?

2) Concerning your tutorial, what is the difference whether you explain the use of Dim or explain the use of VarToArray?

Edit

Forgot to mention that Dim is used in several languages.

Hi,

thanks for the reply.

1) IMO you should always use local or global if you want to create a variable. You do not need the word DIM!

The func I mentioned was just a thought and I think you did not get the point. The only way when Dim is useful, is when you got a variable and want to make an array out of it and store the value in the array.

Maybe I'm not right - then please correct me MVPs.

2) That is not the point. I do not want the word DIM, cause IMO you shouldn't use it. The language should force the user to think about whether the variable should be global or local. That is why I prefer (if I use Opt declare vars) it prevents the user from creating variables with dim.

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Well, personally I NEVER use Dim or Local before my variables... i simply just type out $variable1 = 182 and define the variable that way. I see Dim used quite often to define empty variables Dim $variable1, $variable2 etc. I don't see the use in defining empty variables. If you're planning to set it to 281 later in the script why not just type $variable1 = 281 (add Global if it's in a function and you need the variable for other parts of the script). If there is a specific reason that I am not realizing for defining empty variables before using them, feel free to let me know, I always like to learn new thing ;).


- Dan [Website]

Share this post


Link to post
Share on other sites

The only reason I haven't pushed to remove Dim is compatibility. It will obviously break scripts (including my own in the few places where I use Dim to create an array from a previously declared variable).

dandymcgee, you completely miss the point. It's not about "creating an empty variable". It's about stating your intentions clearly by using a correctly scoped variable. By the way, your method sucks and I hope it bites you in the ass hard (and it will) so maybe you'll learn. Not explicitly declaring a scope (or using Dim) means you can and will trample over a global variable of the same name when you don't mean to. These sort of problems can be hard to debug but are very easy to avoid by writing clear code. If I had my way, "MustDeclareVars" would be permanently enabled with no option to turn it off so people like you are forced to write good code.

Share this post


Link to post
Share on other sites

Hi,

thanks Valik for the reply. So I'm right to write the tut only with local and global variables. (If I do not need the var to array thing)

Compatibility is important, but wouldn't it be easy to fix it?

Nevermind, it is your decision and I got my answer.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hi,

thanks Valik for the reply. So I'm right to write the tut only with local and global variables. (If I do not need the var to array thing)

Compatibility is important, but wouldn't it be easy to fix it?

Nevermind, it is your decision and I got my answer.

So long,

Mega

It's your tutorial so you can write it anyway you want but conider the novice.

He reads your tut and then sees Dim in the AutoIt help file and gets confused. In that situation the tutorial has probably increased the learning curve.

As for broken scripts. Thats always been an issue but it han't (thankfully) been too bad lately. I solved part of the problem by creating a function in my scrip cleaner that looks for old keywords, functions etc. and updates the script [example: If it finds TimerStart() then it will change to TimerInit()] so I could easily make any changes to the Dim keyword very easly. Novices have more of a problem with things like that.

Point? Your Tut should be novice friendly.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

The only reason I haven't pushed to remove Dim is compatibility. It will obviously break scripts (including my own in the few places where I use Dim to create an array from a previously declared variable).

dandymcgee, you completely miss the point. It's not about "creating an empty variable". It's about stating your intentions clearly by using a correctly scoped variable. By the way, your method sucks and I hope it bites you in the ass hard (and it will) so maybe you'll learn. Not explicitly declaring a scope (or using Dim) means you can and will trample over a global variable of the same name when you don't mean to. These sort of problems can be hard to debug but are very easy to avoid by writing clear code. If I had my way, "MustDeclareVars" would be permanently enabled with no option to turn it off so people like you are forced to write good code.

qft.........

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

qft.........

Hi,

http://www.urbandictionary.com/define.php?term=QFT

Quoted For Truth. Generaly used on internet forumafter quoting someone to make sure they cannot go back and change what they've already posted. Sometimes used to express you agree with the opinion. "QFT, brutha." is different from "QFT you ... Peep!"

Brian wrote: I love cock first thing in the morning.

QFT, you dumb .... so you can't say later that you didn't say that.

Yes, thanks GEOSoft. I will keep that in mind.

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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