AutoHotkey Community

It is currently May 27th, 2012, 2:41 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: August 31st, 2005, 7:20 am 
Offline

Joined: February 14th, 2005, 10:54 am
Posts: 447
Location: Texas, Usa
Can we expect to see the ability to call functions from within functions?

I have made several functions for handling fractions, or the basic step with dealing with them. I have made:

MixNum; turns improper fraction into mixed number
ImPropFraction;turn mixed number into improper fraction
Lcd;return least common denominator between a and b
Gcd; return greatest common denominator between a and b
CommonFactor;returns list of common factors of a Num
PriComp;returns if number is prime or composite

now I want to make a function that adds fraction A and fraction B together with those functions. and it can be done with those "steps". I dont want to be rudundant with my code when I do seperate functions for subtraction, multiplication and division of fractions. Is there a easy way to call these functions with in a function? (or simular result) without the use of Gosub, which also seems like a burden, because each function would need the same code or jump to a public routine and that seems like it would get more complex than need be, or is that the only way?

My vision is something like

Myfn(p1,p2)
{
this = MyotherFn(p1,p2)
If this = that
then do this
if this <> that
then do this
Return a result after doing 10 - 15 steps
}

_________________
my lame sig :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 31st, 2005, 7:29 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
I thought you already could :? .
Code:
MsgBox, % test("This")
Return

test(aa)
{
  aa = %aa% is a
  aa := test2(aa)
Return, %aa%
}

test2(aa)
{
  aa = %aa% test.
Return %aa%
}

I have called a function from within a function a few times here also (unless I'm misunderstanding...).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 31st, 2005, 7:34 am 
Offline

Joined: February 14th, 2005, 10:54 am
Posts: 447
Location: Texas, Usa
from the help file:
Quote:
Although a function cannot contain definitions of other functions, it can contain private subroutines. As with other subroutines, use Gosub to launch them and Return to return (in which case the Return would belong to the Gosub and not the function).

then did I mis understand this?

_________________
my lame sig :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 31st, 2005, 7:37 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
I think that means that something like this is not allowed:
Code:
MsgBox, % test("This")
Return

test(aa)
{
  aa = %aa% is a
  aa := test2(aa)

test2(bb)
{
  bb = %bb% test.
Return %bb%
}

Return, %aa%
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 31st, 2005, 7:40 am 
Offline

Joined: February 14th, 2005, 10:54 am
Posts: 447
Location: Texas, Usa
that makes sense now. thanks for the clarification on that! back to work now. :D

_________________
my lame sig :)


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 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