Sign in to follow this  
Followers 0
P388l3s

A question about user created functions...

6 posts in this topic

Hi

I've been lurking on this board for a long time, enjoy the community thats grown up around AutoIT, and this script language is just what the doctor ordered, but to business...

I'm working on a script that uses an array built from a INI using the section names, and then processes those sections one at a time and makes some changes, but the script I'm writing is only really going to work nicely if I can call the function from within itself, thereby creating a cascade effect to sort the changes correctly, I have knowledge and programming experience (although a programmer I do not think I am ;) ) I know this type of thing is possible with C C# and I think Cobol can handle it too, just wondered if anyone here has tried something like this or if any of the Devs or Moderators know if AutoIt can handle a situation like this?

Thanks for your time, and keep up with the great work, this script language is excelent.

Pebbles

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

It's called recursion.

And hmm, did you try? ;) How hard can it be?

Func Add($val)
$val += 10
If $val < 10000 Then Add($val)
Return $val
EndFunc

Local $val = 0
ConsoleWrite(Add($val))

Regarding arrays. That could possibly be tricky depending on how you use the array. Take a look at the array tutorial in the wiki.

EDIT: Removed quote.

EDIT2: Moved ndFunc in code.

Edited by Uten

Share this post


Link to post
Share on other sites

Thanks, yes I know what it is (Recursion, but the word eluded me) but it's been a VERY long time since my days at School/College doing programming and to be honest it's not my best suit, but here I am with an itch that needs scratching and so I'm scratching away, but as for the question, I thought I'd ask before slamming my forehead against the wall.

As for the array, I'm not using the array itself in the function just data extracted from the array, although I may need to create arrays within the function to deal with some of the recursion branches, I'm basically inquiring to find if the language is powerful enough to handle such events, an honest question I believe.

Pebbles

Share this post


Link to post
Share on other sites

Thanks, yes I know what it is (Recursion, but the word eluded me) but it's been a VERY long time since my days at School/College doing programming and to be honest it's not my best suit, but here I am with an itch that needs scratching and so I'm scratching away, but as for the question, I thought I'd ask before slamming my forehead against the wall.

As for the array, I'm not using the array itself in the function just data extracted from the array, although I may need to create arrays within the function to deal with some of the recursion branches, I'm basically inquiring to find if the language is powerful enough to handle such events, an honest question I believe.

Pebbles

Certainly is an honest question. I do believe his point was that you could have easily looked it up in the help file. But then again you had forgotten the proper word so no big deal. ;)

I would also recommend you look into possibly using loops. As you need help please feel free to post your code here in the support forum and there will be many responses if you pose your question properly and supply some code. When you do supply code please use the [ autoit ]...[ / autoit ] tags. (NOTE: Remove the whitespace)

It sounds as though there may be a better way to do what you are trying to do with the recursion. I suggested loops due to AutoIt having a recursion limit. I don't know what the limit is, but I know it exists.

Also to brief yourself on most of AutoIt's abilities I would recommend using Valuater's Welcome to AutoIt 1-2-3.

I hope this helps you on your way,

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

Thanks, yes I know what it is (Recursion, but the word eluded me) but it's been a VERY long time since my days at School/College doing programming and to be honest it's not my best suit, but here I am with an itch that needs scratching and so I'm scratching away, but as for the question, I thought I'd ask before slamming my forehead against the wall.

As for the array, I'm not using the array itself in the function just data extracted from the array, although I may need to create arrays within the function to deal with some of the recursion branches, I'm basically inquiring to find if the language is powerful enough to handle such events, an honest question I believe.

Pebbles

Well, without ANY description of what you want to do with the array and some sample data, how can we tell you if AutoIT/you is/are capable of doing it? So, post some more information and some sample data and the chances to get a valuable answer will raise ;)

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

Thanks, yes I know what it is (Recursion, but the word eluded me) but it's been a VERY long time since my days at School/College doing programming and to be honest it's not my best suit, but here I am with an itch that needs scratching and so I'm scratching away, but as for the question, I thought I'd ask before slamming my forehead against the wall.

As for the array, I'm not using the array itself in the function just data extracted from the array, although I may need to create arrays within the function to deal with some of the recursion branches, I'm basically inquiring to find if the language is powerful enough to handle such events, an honest question I believe.

Pebbles

I think I gave you an honest answer. With a sample to prove the concept.

But yes, unfortunately, I did misplace the EndFunc kyeword it should have been two lines up. I have fixed it in my previous post.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0