Page 2 of 3

Re: Questions, questions...

Posted: 08 Oct 2013 14:40
by Yanus
.

Re: Questions, questions...

Posted: 08 Oct 2013 22:04
by Yanus
.

Re: Questions, questions...

Posted: 09 Oct 2013 07:42
by Eowul
Yanus wrote:Why args.length is undefined?
In what scenario?

Re: Questions, questions...

Posted: 09 Oct 2013 13:15
by Yanus
.

Re: Questions, questions...

Posted: 18 May 2014 09:21
by Arcon
Is there anyway to set up a macro?
I am so used to have 0 as a "h all" macro and I hit it obsessively.

Re: Questions, questions...

Posted: 18 May 2014 12:59
by Zhar
Yanus wrote:Alias.
Name: bromba
Type: javascript
Body:

Code: Select all

gwc.output.append(args.length);
gwc.output.append(args[1]);
Input:

Code: Select all

bromba alalala
Output:

Code: Select all

undefined
alalala
args is an object, objects in JS have no length property and that's what's causing it to be undefined. You can iterate through them but you can't invoke array-specific functions on them (like length).

More reading: https://www.inkling.com/read/javascript ... ke-objects

Re: Questions, questions...

Posted: 18 May 2014 14:43
by Yanus
.

Re: Questions, questions...

Posted: 18 May 2014 17:07
by Zhar
Yanus wrote: @Zhar
That's the ancient problem.
Your example isn't 100% clear to me, but hopefully some of this helps? If you are actually passing in an argument like args, then its possible in your example that args could be an object, not an array.

Code: Select all

var obj = {};
obj[1] = 'test';
Above would be an example where your obj[1] would return a value but length would not be known.

If you are actually trying to access the arguments of a function, then, the keyword is arguments and it isn't passed into the function, its just kind of there.

What happens if you change the code to:

Code: Select all

gwc.output.append(arguments.length);
?

Re: Questions, questions...

Posted: 18 May 2014 23:00
by Yanus
.

Re: Questions, questions...

Posted: 19 May 2014 08:59
by Arcon
Yanus wrote:@Arcon:

What do you mean by that? Is macro being fired up on pressing the key (without the need to press Enter afterwards)?
I don't think it's possible at the moment.

@Zhar
That's the ancient problem.
Yes. in Zmud I have the 0 on the numpad as h all and I hit it compulsively all the time.