eyeguy Posted April 26, 2012 Posted April 26, 2012 Hi I am not sure if this forum is the best to post this query. I have what I think is a very basic question. I have a dialog box with a pop up menu. The user selects a value I then have a calculation which goes something like: " If choice 1 or choice 2 or choice 3 then do this OR if choice 4 or choice 5 then do another. I have done this in the context of a case function. This seems inelegant. Is there a neater way to determine which calculation to perform based on the user choice without all the "or's" Joseph
mr_vodka Posted April 26, 2012 Posted April 26, 2012 Can you explain further what you are trying to do with the true context ( not concerning technique or hypothetical scenarios )
eyeguy Posted April 27, 2012 Author Posted April 27, 2012 Yes The user selects a value from a popup menu. Depending on the choice a script will run. Thus if they select value "a" or "b" or "c" then each of these will trigger the SAME script but if they select "d" or "e" or "f" then a different script will run. My question is how can avoid the "if a or b or c " and instead somehow lump the a, b, c together and the d,e,f together? Joseph
comment Posted April 27, 2012 Posted April 27, 2012 Try something like = not IsEmpty ( FilterValues ( "a¶b¶c" ; YourTable::SelectedValue ) ) Note that this is a purely cosmetic adjustment; functionally, it's the same as = YourTable::SelectedValue = "a" or YourTable::SelectedValue = "b" or YourTable::SelectedValue = "c"
eyeguy Posted April 27, 2012 Author Posted April 27, 2012 So is anything gained by this approach? I guess my question is based on creating more efficient code which in turns translates into faster execution
comment Posted April 28, 2012 Posted April 28, 2012 I don't know, it needs to be tested. Offhand, I wouldn't expect the difference to be significant.
Vaughan Posted April 29, 2012 Posted April 29, 2012 So is anything gained by this approach? I guess my question is based on creating more efficient code which in turns translates into faster execution Be careful of "premature optimisation". It might a fine achievement shaving a couple of minutes off a 7 minute process, however if the process is only run once a week there is little benefit to the client. On the other hand, saving a second from a process that is performed several times an hour will have a huge impact. IMHO get the whole solution working and into production, THEN look at where optimisations can be made that will provide a return on the investment.
Recommended Posts
This topic is 4592 days old. Please don't post here. Open a new topic instead.
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 accountSign in
Already have an account? Sign in here.
Sign In Now