April 26, 201213 yr 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
April 26, 201213 yr Can you explain further what you are trying to do with the true context ( not concerning technique or hypothetical scenarios )
April 27, 201213 yr Author 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
April 27, 201213 yr 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"
April 27, 201213 yr Author 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
April 28, 201213 yr I don't know, it needs to be tested. Offhand, I wouldn't expect the difference to be significant.
April 29, 201213 yr 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.
Create an account or sign in to comment