AutoHotkey Community

It is currently May 26th, 2012, 7:25 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 

What do you think of this idea?
It's a good idea.
It's a bad idea.
I like cheese.
You may select 1 option

View results
Author Message
PostPosted: April 18th, 2008, 1:34 pm 
Offline

Joined: February 16th, 2008, 12:28 am
Posts: 43
I would like to see the ability to use functions in addition to labels for setTimer and anywhere else labels can be specified as target code to be invoked, with a standard list of parameters that will be passed to the function when it's called.

Currently, every time I set a target label all I do is immediately call a function anyway - I try to avoid gosubs of any kind no matter what language I'm using.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 18th, 2008, 8:08 pm 
Offline

Joined: April 17th, 2007, 1:37 pm
Posts: 761
Location: Florida
Piz wrote:
I try to avoid gosubs of any kind no matter what language I'm using.
Why would you do this? I'm in the process of learning programming and kind of like being able to break things up into different parts by assigning different labels to them.

_________________
[Join IRC!]
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 18th, 2008, 8:35 pm 
Offline

Joined: March 19th, 2006, 5:52 am
Posts: 419
GoTo and GoSub can result in code that is hard to follow if there is too much jumping around. You also leave yourself open to some variable troubles as things are not scoped.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 18th, 2008, 9:14 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1933
Location: Germany
It is good to have both. I voted for yes. Often, in complex scripts, I am also trieng to avoid subroutines and do need them only for wrapping function calls.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 18th, 2008, 9:37 pm 
Offline

Joined: April 17th, 2007, 1:37 pm
Posts: 761
Location: Florida
I think I've been using the idea of a function and a subroutine somewhat interchangeably.

I've used functions very little because I didn't want to be bothered with learning how to use them since I've done pretty well using subs... I can see where a few of my scripts would have been easier to write/follow when using a function instead of a subroutine, though.

Thanks for the info.

_________________
[Join IRC!]
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 18th, 2008, 11:20 pm 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3328
Location: Simi Valley, CA
In my mind, a labeled subroutine is just a place, but a function is a thing to do.

For example, "Brothel" would be a label, while "Paid_Entertainer" would be a function.

Although you can do lots of things at a brothel, there are some things that a paid entertainer can do, places they can go, etc, that a brothel just can't accommodate.

For instance, how would a timer handle a function with a return value ? And how would it be different from
Code:
SetTimer, Somewhere, 1000
Somewhere:
var := SomeFunction( things )
return
???

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 27th, 2008, 4:29 pm 
Offline

Joined: December 19th, 2006, 2:14 pm
Posts: 72
Location: France
Hi all

Why I'd like to be able to call functions instead of labels for timers & al ?

Simple : I like not to have lingering global vars. So when I need a var in the timer code, the Timer branch calls a function in which I can declare locals which will not linger when timer code ends.

I'd really like to avoid label-to-function wrapping code.
Piz wrote:
with a standard list of parameters that will be passed to the function when it's called
or with nothing at all :)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group