Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to implement polymorphism in aspect scripting

Status
Not open for further replies.

polluxtech

Programmer
Dec 14, 2009
15
CN
Hi all friends, need help:
I have a string array ["abc","efg","hig"] named methods and three functions
abc() efg() hig()

I want to do something like this:

if methodname=="abc"
call abc
else if methodname=="efg"
call efg
else methodname == "hig"
call hig

but this is not neat,right? I would like to write single line code like below, but this is not allow in aspect scripting, what and how to do? help

call methods
 
sorry,my mistake

methodname =="abc" change to strcmp methodname "abc" maybe better to understand
 
If I understand correctly, I think probably the cleanest way to do this would be with a switch/case structure, but that still won't get you a one-line solution.

 
thanks knob, switch/case is better, but...
my mean is that:
String methods [3]
methods[0]="abc"
methods[1]="efg"
methods[2]="hig"

then i define three functions:
func abc
....
endfunc

func efg
...
endfunc

func hig
...
endfunc

I want to do this:
integer methodId
methodId=getMyMethodId()
call methods[methodId]

how to get the right way? Thanks help help help
 
I know, I think you make me wrong. :)

call methods[methodId]

methods just a string array , methods[methodId] just return one of values of "abc" "efg" "hig"

call methods[methodId] is call functions abc, efg, hig dynamically, I won't to write switch/case structure, because I have many many thus functions. This works fine in linux shell, but did not support in aspect scripting.

So my question is that how to do that in aspect scripting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top