Jump to content

mysterious $i & $h


Recommended Posts

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 :)

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

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
Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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.

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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
Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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
Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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
Link to comment
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.

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

Link to comment
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.

Link to comment
Share on other sites

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

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...