Hello,
I am a new user of MS since 3 weeks only and this is my first post to this forum.
I have already experimented quite a lot and already produced running EXE in this short time.
However, for sure, I have still a lot to learn about MS.
Variable localization nesting effect of it and parameter passing to a Sub are clear concepts for me.
I do not like utilization of global variables if not strictly necessary.
I have also understood that it is possible to write VBA code in MS to exploit functions and pass ByRef or return variables via functions in VBA style.
My Question:
Can you recommend me the best, efficient and elegant way to create a function like code in MS to return back parameters to the caller code without using global variables?
- Please to make me a simple example
- I would like to know also how to return back arrays and complex data.
Before starting to use intensively MS I would like to clarify this point.
Massimo
Passing back parameters from sub to calling script
Moderators: Dorian (MJT support), JRL
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: Passing back parameters from sub to calling script
Hi,
Subroutines do not return values. So you would need to use global variables. I would advise creating variables that have the subroutine name as a prefix to avoid confusion.
Note that in other programming languages subroutines don't return values either. Functions do. Subroutines do not. At present Macro Scheduler doesn't have native functions, just subroutines.
Subroutines do not return values. So you would need to use global variables. I would advise creating variables that have the subroutine name as a prefix to avoid confusion.
Note that in other programming languages subroutines don't return values either. Functions do. Subroutines do not. At present Macro Scheduler doesn't have native functions, just subroutines.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: Passing back parameters from sub to calling script
Thanks.
In the meantime I have used this method.
Good idea to exploit name of variable like the Sub Name
I hope that it is in your plans to extend MS to functions.
Anyway, very nice tool.
Massi
In the meantime I have used this method.
Good idea to exploit name of variable like the Sub Name
I hope that it is in your plans to extend MS to functions.
Anyway, very nice tool.
Massi
Re: Passing back parameters from sub to calling script
@Marcus,
I mean, I'm just saying that's like the best idea in the last 5 minutes.
Which raises the question, when do you think v15 might hit the market?
PepsiHog
Great idea! Is this in your to-do list? It should be. At the top, preferably.At present Macro Scheduler doesn't have native functions, just subroutines.
I mean, I'm just saying that's like the best idea in the last 5 minutes.
Which raises the question, when do you think v15 might hit the market?
PepsiHog
Windows 7
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!
PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)
The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!