New topic: Accessing Methods and Properties based on user input
<http://forums.realsoftware.com/viewtopic.php?t=30595> Page 1 of 1 [ 2 posts ] Previous topic | Next topic Author Message klossman Post subject: Accessing Methods and Properties based on user inputPosted: Wed Oct 21, 2009 10:54 pm Joined: Thu Apr 12, 2007 8:27 am Posts: 12 I have a problem that I haven't been able to figure out and I'm hoping someone out there can help me... I have a list of properties labeled PID01 to PID30 and each one can hold a certain type of string data...I also have methods to set the data and to get the data...so far, so good...what I need to be able to do, is allow the user to select any one of these PID's and map them to any other PID field. Basically, say I need the contents of PID03 copied over to PID30... The question is how do I at runtime call the proper method for that fields Get method in order to get the contents and then call the proper Set Method of the field to be copied...Keep in mind, any field can be copied to any other field... Example of what I was thinking was: SetPID30(GetPID03) I can't figure out how to run the Set Method and Get Method combination because I have no idea what the user will need to do at the time.... I hope this isn't too confusing Thanks Kenny Top timhare Post subject: Re: Accessing Methods and Properties based on user inputPosted: Wed Oct 21, 2009 11:08 pm Joined: Fri Jan 06, 2006 3:21 pm Posts: 6603 Location: Portland, OR USA The most straightforward way is a couple of select case statements. Code:dim theValue as string select case PIDToGet case "PID01" theValue= GetPID01 case "PID02" theValue= GetPID02 case ... end select case PIDToSet case "PID01" SetPID01(theValue) case "PID02" SetPID02(theValue) case ... end There are more elaborate ways involving delegate and dictionaries, but sometimes, brute force just fits the bill. Tim Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 2 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
