Jump to content

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

Alias


  • Please log in to reply
27 replies to this topic
corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004
- Assign a variable name to a specific address/range in memory
Alias("VarName", &SomeOtherVar + 4, Length)
- Assign an expression to be evaluated when a specific variable is referenced (value is requested)
MyResult := Alias(MyFunction(param1, param2) + 20 + SomeGlobalVariable)
MsgBox % DllCall("MyDll.dll\Egad", "UInt", MyResult, "Str", "This is a useless example")


Grumpy
  • Guests
  • Last active:
  • Joined: --
:?:
I fail to see the usefulness of the first one (and how it is related to the second one).
And for the second, you can just write another function...

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004

:?:
I fail to see the usefulness of the first one (and how it is related to the second one).
And for the second, you can just write another function...

Why am I not surprised? The uses are obvious. Don't be a pest.

The first one would mainly be used for simplifying struct usage by allowing a variable name to be assigned for a specific offset of another variable but could also be useful in many cases where a specific location in a variable needs to be accessed frequently.

The second one is a user friendly shortcut to calling a function but gives the look/feel of creating an A_ style variable. Useful when creating #Include files to simplify usage for a user. For example:
If InStr(RE_Text, "Grumpy")
  ExitApp
In the example above RE_Text could retrieve the text from a RichEdit control without having to call a function by name and specify a HWND, etc... There are many other examples where this could be handy. Unfortunately I don't have much time to give a more detailed response at the moment but I can try and elaborate later if you don't understand the usefullness of the concept.

The combination of the two could also greatly simplify struct usage...

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004

And for the second, you can just write another function...

Expressions are not supported in all commands but variables are...

Grumpy
  • Guests
  • Last active:
  • Joined: --

Don't be a pest.

You wish for something. Chris isn't a fairy, so would like some explanations.
I don't write "this is stupid!", but rather "convince me"... ;)

The first usage might be redundant with some real struct support.
Both might (or not) be covered by a (hypothetical yet) preprocessor, no?

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

Assign a variable name to a specific address/range in memory

Alias("VarName", &SomeOtherVar + 4, Length)

This can't be easily done because a variable must know its own capacity. The script could specify the capacity; but that would be cumbersome even assuming it knows the capacity. Another complication is freeing the memory: the program would then be unable to free the memory so would have to set an internal flag indicating that the memory is off-limits and never to call free() on it.

Assign an expression to be evaluated when a specific variable is referenced (value is requested)

MyResult := Alias(MyFunction(param1, param2) + 20 + SomeGlobalVariable)
MsgBox % DllCall("MyDll.dll\Egad", "UInt", MyResult, "Str", "This is a useless example")

If I understand correctly, this seems like a repeat of a previous wish. It's The benefit/cost doesn't seem that high to me because it's a low-level change that might add a lot of code and reduce performance (even in scripts that don't use the feature).

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004

This can't be easily done

It's very rare that anything worthwhile is easy to do but that doesn't mean that it isn't worthwhile.

Well, if you don't see the benefit in either of these now then I doubt that trying to explain them any further will do any good. Never mind. I'll code them in myself. cya.

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004

You wish for something. Chris isn't a fairy, so would like some explanations.
I don't write "this is stupid!", but rather "convince me"... ;)

No, you're just being a pest and it's annoying. I'm sure that Chris understood just fine with the original post. Btw, the guest nick is also annoying...

Grumpy
  • Guests
  • Last active:
  • Joined: --
Now, who is grumpy? :D

daonlyfreez
  • Members
  • 995 posts
  • Last active: Jan 23 2013 08:16 AM
  • Joined: 16 Mar 2005
:shock:

Slow down please...
Posted Image mirror 1mirror 2mirror 3ahk4.me • PM or Posted Image

Grumpy
  • Guests
  • Last active:
  • Joined: --
With an initial lower case:
http://www.wordrefer...finition/grumpy

grumpy
A adjective
1 crabbed, crabby, cross, fussy, grouchy, grumpy, bad-tempered, ill-tempered
perversely irritable

8)

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
It's true I don't see a large benefit to these suggestions. Perhaps if others wanted them too, it would help. It would also be good to have more examples in which the features would greatly simplify or improve things.

Also, it would be good to know if other scripting languages have such a feature. Usually if they don't it's not because they simply haven't thought of it; it's because the benefit/cost isn't that good.

sanitarium
  • Members
  • 28 posts
  • Last active: Jun 11 2007 04:41 AM
  • Joined: 08 Jun 2007

Now, who is grumpy? :D

I guess you don't need the nick then...

majkinetor
  • Moderators
  • 4512 posts
  • Last active: May 20 2019 07:41 AM
  • Joined: 24 May 2006
Aha, massive killer from the "My name is Morphy" case is back.

Hail !
Posted Image

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004

Now, who is grumpy? :D

I guess you don't need the nick then...

Hmm... Now who was that?