Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Very simple object property question



  • Please log in to reply
10 replies to this topic
Benny-D
  • Members
  • 1485 posts
  • Last active: Sep 27 2016 11:23 PM
  • Joined: 29 Feb 2008

Can you, please, explain t me the difference between:

 

fog := [ ]
fog[1] := "thick"

 

and

 

fog := [ ]
fog.1 := "thick"

 

I guess the latter one is a property and the former is not. But still what difference does it make?

Is there something essentially different here?



Ohnitiel
  • Members
  • 755 posts
  • Last active: Sep 08 2016 06:26 PM
  • Joined: 25 Aug 2011

The first one is a array, the second is a pseudo-array. At least that what i think it is.


Let us not be lazy. Someday it might just kill us.

Frozhax
  • Members
  • 87 posts
  • Last active: Jun 14 2015 02:03 PM
  • Joined: 03 Aug 2013

nevermind, i'm a retard



kon
  • Members
  • 1652 posts
  • Last active:
  • Joined: 04 Mar 2013
✓  Best Answer

They are equivalent. Inside [] you can have keys that are: 1. variables containing numbers/strings 2. quoted strings or 3. Pure numbers. If you use the dot-syntax, strings are not quoted but spaces can't be used ie. MyObj.KeyOne and MyObj["Key One"] are valid but MyObj.Key One is not valid.
 

All types of objects support both array syntax (brackets) and object syntax (dots).

 
 MyObj := []
MyObj.KeyOne := "one"
MyObj["KeyTwo"] := "two"
Var := "KeyThree"
MyObj[Var] := "three"

Var := "KeyTwo"
MsgBox, % MyObj["KeyOne"] "`n"
    . MyObj[Var] "`n"
    . MyObj.KeyThree
return
 

It is not a pseudo array. A pseudo array is when a number is appended to a variable like: MyVar%a_index% := "Some Value"



Benny-D
  • Members
  • 1485 posts
  • Last active: Sep 27 2016 11:23 PM
  • Joined: 29 Feb 2008

Thank you Kon!

 

I see in your message there are some links leading to AHKScript.org forum that looks somewhat an official forum of AHK.

But why then we have this one that also looks quite official to me? What's the difference between AHKScript.org and www.autohotkey.com forums?



Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

It's pointless to call either one "official" IMO. This site used to be THE AutoHotkey site, but is now controlled by polyethene, who does not and never did develop AutoHotkey itself (only his own apparently abandoned rewrite, IronAHK). ahkscript.org is hosted by tank, but myself and several other users have the power to Do Things.  There are other reasons to choose one site or the other, but I won't go into that.

 

 

They are equivalent. Inside [] you can have keys that are: 1. variables containing numbers/strings 2. quoted strings or 3. Pure numbers.

 

You can have any valid expression which produces a value, not just variables and literal values.



Benny-D
  • Members
  • 1485 posts
  • Last active: Sep 27 2016 11:23 PM
  • Joined: 29 Feb 2008

Hi, Lexikos!!!

 

Thanks for this clearification, but I still have some questions here. Would you please also answer them?

 

1) You said:

 

"This site used to be THE AutoHotkey site, but is now controlled by polyethene, who does not and never did develop AutoHotkey itself"

 

When did this split between polyethene and others took place? Was it around that time when Chris departed and AHK kind of diverged into AHK and AHK_L? I was't visiting too often during that time, but, as far as I remember, it was almost like a war going on between those who would see AHK as the "official" thing and those who would want to see AHK_L as the official one. I even remember there was a time when both versions were offered to be downloaded on this site. Now, as far as I understand, it's all in the past.

 

2) As far as I understand, www.autohotkey.com sticks to AHK_L  - it is has the name "AHK", but what's inside is essentially AHK_L, not the original AHK created by Chris  (Chris's  version, as far as I understand, didn't have objects and Unicode). So what about ahkscript.org in this regard? Do they also stick to AHK that is essentially AHK_L or do they still keep the original classical AHK vreated by Chris?

 

3) You said:

"ahkscript.org is hosted by tank, but myself and several other users have the power to Do Things"

 

So, where can you personally be found more often, on www.autohotkey.com or on ahkscript.org?



joedf
  • Administrators
  • 986 posts
  • AutoHotkey Foundation
  • Last active: Nov 02 2019 08:38 PM
  • Joined: 20 May 2012

Hi Benny-D,

You should read the following:

- http://ahkscript.org...ahkscript:About

http://ahkscript.org...c.php?f=2&t=466

 

regards


Why ahkscript.org? - autohotkey.com is outdated

AfterLemon
  • Moderators
  • 237 posts
  • Connoisseur of Boobs
  • Last active: Jan 04 2016 11:12 PM
  • Joined: 09 Oct 2012

To clarify Lexikos's statement about arrays with the [bracket] vs .dot syntax.

"a[1]:= b" == "a.1:= b" ; These are equivalent due to the interpretation of [1] as the key reference, and .1 as the calling of the value by its inherent key-method.

More Examples:

"a[VarContaining1+1]:=1" == "a.2:=1" ; [] can contain expressions
"a["blah"]" == "a.blah"

For the method calling, these are the same:

"a["show"]()" == "a.show()" ; These are equivalent because the value inside [] is treated as an expression, while .show is treated as a literal.

This is handy due to the inability to do anything like a.%varcontainingShow%() ; you would use a[varcontainingshow]() for the same effect.

"a[VarContainingShow]()" =/= "a.%VarContainingShow%()" ; These are not equivalent because obj.%var% is not proper syntax. Will throw an error.


Benny-D
  • Members
  • 1485 posts
  • Last active: Sep 27 2016 11:23 PM
  • Joined: 29 Feb 2008

Thank you joedf for those links. Now I wonder if I should also open an account on that autohotkey.org too.

 

AfterLemon, thanks for the examples!



joedf
  • Administrators
  • 986 posts
  • AutoHotkey Foundation
  • Last active: Nov 02 2019 08:38 PM
  • Joined: 20 May 2012

Thank you joedf for those links. Now I wonder if I should also open an account on that autohotkey.org too.

 

why not? ;)


Why ahkscript.org? - autohotkey.com is outdated