TheDcoder

mysterious $i & $h

51 posts in this topic

Hello again  :bye:,

A lot of times I have seen i or h prefixed to variables in UDFs (Ex. $iColour, $hWnd etc.) although their function seems like a normal variable... Is there any reason or specific purpose for prefixing them :huh:?

I personally think that this is a style of programming in AutoIt  b/c I have noticed that ISN AutoIt Studio pops up a very tiny colour selection palette whenever there is a $iColour parameter in a function.

What do you think i & h are for?

(I posted in dev chat b/c its more suited for this section compared to general support section :D)

TD :)


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

That article contains misleading information. Variables are not initialised as all the different values indicated (some of which are actually undefined). Variables are intialized as empty strings by default regardless of any prefix. I'm not sure why the second column is there. I guess the author of that article meant to say that these values are his, or her, recommended suggestions.

Edited by czardas

Share this post


Link to post
Share on other sites

I agree, I was confused too with it..


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

@All

Then take some of your spare time and fix the article :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - 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

It would first be nice to know exactly what was intended. I'm also not 100% happy with the use of $k for keyword, although I believe this has been hashed out previously by others. My objection is that 'k' is frequently used to denote a constant in physics. This has been copied by some programming languages already, and I'm not comfortable with conflicting conventions.

Share this post


Link to post
Share on other sites

But we could at least correct obvious errors.

Example:

"Variables are initialized with the "default" value (or the most efficient value) of their type."

That's not true. Every variable is set to type String with length 0.

Global $iVar
MsgBox(0, "", "IsKeyword: " & IsKeyword($iVar) & @CRLF & _
"VarGetType: " & VarGetType($iVar) & @CRLF & _
"StringLen: " & StringLen($iVar))

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - 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

Agreed water. I will have a think how to word it better. I'm a bit hung over this morning, and I prefer to make modifications when I have a clear head. So I'll fix it shortly. Right now I need some breakfast. :)

Share this post


Link to post
Share on other sites

I have already started and copied some text from Wikipedia which should give new users a better understanding.

I have fixed the default values for newly defined variables and modified the table header from "initialization" to "examples". I would prefer to have real examples not just the prefixes used in this column.

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - 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

#11 ·  Posted (edited)

I think you did a better job than I would have. :) Thanks. Looking further I'm a little bemused by some of the stuff. For example:

Always initialize a variable on it's declaration, and declare all the same type of variable on the same line.

 

That seems a strange statement to me, in both respects. Every piece of code is different.

Edited by czardas

Share this post


Link to post
Share on other sites

I think somewhere on this page a sentence like "This are suggestions to improve the queality of your code. You do not need to follow them but most coders do as you can see in the long list of available UDFs" (or something similar) is needed.

Where it isn't obvious an explanation why a coding practice is being suggested should be added (helpful at least for beginners).

Just my 0.02 $


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - 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

#13 ·  Posted (edited)

Again I agree that more explanation would be helpful. Actually I would mention several other criteria and try to remain impartial, since there is a degree of personal preference regarding best practices. I would say that it is important to understand that variables should not be taking up memory before being used: so you should only assign values as and when needed. This is in some ways contradictory to the statement above. It also appears that the examples are intended to illustrate a similar (or related) principle, but I would harldy ever redeclare a variable in my own code. I might one day initialize a zero element array prior to use, but not without good reason.

For me things have to follow a consistant and logical course. That also applies to layout. Readability and optimization are often in conflict, and the best layout will vary according to circumstance. Laying your code out in a way which always makes sense isn't something that can be easily formalised into a set of precise instructions.

Edited by czardas

Share this post


Link to post
Share on other sites

Next think I want to do is remove wrong content like "The Hungarian notation is adopted however it's simplified and regroup all the types of numbers in one type."

We have at least 3 (i, f and n) in the following table so I would remove this part of the sentence.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - 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

#15 ·  Posted (edited)

I have made some additional modifications (unfinished) which can easily be reversed. I have removed some information temporarly:

Variables should be initialized with the "default" value (or the most logical representation) of their type.

 

I think a new section should be created to address initialisation because I consider it a subject worthy of its own heading.

Edited by czardas

Share this post


Link to post
Share on other sites

One of the things I really appreciated when I first started using AutoIt, was how basic and normal looking things were, without tricky little issues.

Sadly, it has moved on from there and we now have all sorts of things.

Sometimes, I think that when we started to go this route, it should have become AutoIt v4.

Just my two cents, and just saying, as I know it is too hard to go back now.

I kind of feels like the trusty old reliable and endearing wife, has been replaced by the young sporty model who has a big list of demands that she seduces you into with her eroticism.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

Actually the language has advanced greatly, but the ease of use for beginners has not been affected so much. You can still let the interpreter handle a lot of things for you internally, such as scope. Doing so may not be the best way to wriite code, but flexibility makes AutoIt popular amongst first time coders. Standards should be maintained and I have to say that guinness and others have contributed a great deal in raising standards. I believe it's a question of striking a balance, to cater for both beginners and more advanced users at the same time. Some things may have been overlooked in the drive for improvement, which is perhaps to be expected considering the amount of detail involved at a higher level.

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Progress has its advantages and disadvantages, and time doesn't stand still, so one has to move with the times.

I reminisce for the simpler times of my childhood too, but alas it can never be again, and it had its faults anyway.

Such is life.

P.S. And on another level, as I've stated before, I'm very impressed with what has been achieved by guinness and others, and see the current team as pretty damn good, despite some losses.

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

I assume American spelling is prefered over English spelling for the wiki. I sometimes have to think which spelling is correct. In Britain, American English is considered a corruption of the proper language, but it is most widely used on the internet. Someone should make a conversion utility in AutoIt. :)

Thoughts! :think:

Edited by czardas

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

Before I go any further, please could someone give feedback on the changes made to the first two sections. Is it clear or not? Thanks!


Any ideas what the word 'transition' refers to in this sentence?

To make the transition, the variables are also named according to their scope.

Edited by czardas

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