Sign in to follow this  
Followers 0
BruceCopperField

Passing A Lot of Parameters to A Function

6 posts in this topic

I need to pass a lot of parameters to a function. They are part of a larger logical record. In C/C++, I can use struct type and just pass a single pointer to the struct. Is there any similar facility in AutoIt? I don't want to put a long list of parameters into the function definition. Is there anyway to shorten the list of parameters?

Share this post


Link to post
Share on other sites



I need to pass a lot of parameters to a function. They are part of a larger logical record. In C/C++, I can use struct type and just pass a single pointer to the struct. Is there any similar facility in AutoIt? I don't want to put a long list of parameters into the function definition. Is there anyway to shorten the list of parameters?

You could put them all in an Array and pass the Array as ByRef. :)

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

You could put them all in an Array and pass the Array as ByRef. :)

But my parameters are of different types. I know I can put different types in Array, but is it a good design to do so?

Share this post


Link to post
Share on other sites

Don't see an issue with that really. Anything specific you think could be an issue ?

Jos

It works. ..but it is definitely not a good programming style. Just like we don't have to declare the variables but problems are going to appear if our script is getting very large and complex. There is why record/struct datatypes are created in addition to Array in other programming languages.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

It works. ..but it is definitely not a good programming style. Just like we don't have to declare the variables but problems are going to appear if our script is getting very large and complex. There is why record/struct datatypes are created in addition to Array in other programming languages.

Welcome to a typeless (variant) language and how it is up to you to check the type of variable used. The functions are there to check variable types so no reason why you cannot succeed. Good luck. :) Edited by MHz

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