Hi,
Is it possible to have optional parameters in procedures?
It was something I was thinking about a while back when writing some code.
We have a list of 5 pairs e.g.
1 - apple
2 - orange
3 - banana
4 - grape
5 - melon
or something.
In the end I wrote 2 procedures with different names and different input/outputs.
One procedure would take an int and return the related char the other would take a char and return the related int.
Is it possible for a procedure to take different types of params and send back different things based on this.
i.e. if the param is an int it will return the char and if the param is a char it will return the int?
I know this is possible (kind of) in java by creating 2 methods with the same name but different input params. The runtime environment will then work out which method to run based on the type of input it gets.
Hope this makes sense.
Thanks
Oliver
You didn't tell anything about your Progress version.
Procedures don't support that at all! Classes (object oriented programming) does. OO code can be mixed with procedures in a variety of ways. A class with static methods supports overloaded methods (same name, different parameters) and is really simple to use as it does not require instantiation.
Static memebers are supported since 10.1C. OO coding sine 10.1A.
Thanks!
We're using 10.1B but we haven't got any OO stuff
TBH I haven't really learnt anything about OO programming in Progress. (How to do it or it's advantages etc...)
::EDIT:: Found the OO manual
Looks fairly accessible given my Java background. Also looks like there are some solutions to problems I came across but never managed to resolve a while ago.
Thanks for the help.
P.S. Ever wish you could start again on the program you are developing and rewrite it from the ground up?
Starting over is sometimes the best route ... especially if you discover that you have done something wrong. Don't be afraid to get started with the OO in baby steps, i.e., just encapsulating some small piece of behavior. E.g., if you need to do this conversion a bunch of times, pre OO it would have been logical to put it into a persistent procedure. Now you can put it in a class and be that much more elegant.
tamhas wrote:
Starting over is sometimes the best route ... especially if you discover that you have done something wrong. Don't be afraid to get started with the OO in baby steps, i.e., just encapsulating some small piece of behavior. E.g., if you need to do this conversion a bunch of times, pre OO it would have been logical to put it into a persistent procedure. Now you can put it in a class and be that much more elegant.
Same goes for moving to .net ...