Replace conditional statement with Polymorphism

Philip Tulett philip.tulett at
Sat Jul 2 18:06:19 UTC 2022

Hi Martin,Corrected!That looks like:-Calculate lPixels as int(lColLength/5)If mod(lColLength,5)   Calculate lPixels as lPixels+1End IfKind regards Phi
-------- Original message --------From: Martin Obongita via omnisdev-en <omnisdev-en at> Date: 02/07/2022  18:49  (GMT+00:00) To: OmnisDev List - English <omnisdev-en at>, Rob Mostyn <mostyn at> Cc: Martin Obongita <martin.obongita at> Subject: Re: Replace conditional statement with Polymorphism  Hi Rob,I have a report class in which I want to display columns.The length of the columns should depend on the longest data in that column.I get the data and approximate its length in pixels.Calculate lColLength as pColLengthIf lColLength<=5Calculate lPixels as 1Else If lColLength<=10Calculate lPixels as 2Else If lColLength<=15Calculate lPixels as 3Else If lColLength<=20Calculate lPixels as 4Else If lColLength<=25Calculate lPixels as 5Else If lColLength<=30Calculate lPixels as 6Else If lColLength<=35Calculate lPixels as 7Else If lColLength<=40Calculate lPixels as 8Else If lColLength<=45Calculate lPixels as 9Else If lColLength<=50Calculate lPixels as 10Else If lColLength<=55Calculate lPixels as 11Else If lColLength<=60Calculate lPixels as 12Else If lColLength<=65Calculate lPixels as 13Else If lColLength<=70Calculate lPixels as 14Else If lColLength<=75Calculate lPixels as 15Else If lColLength<=80Calculate lPixels as 16Else If lColLength<=85Calculate lPixels as 17Else If lColLength<=90Calculate lPixels as 18Else If lColLength<=95Calculate lPixels as 19Else If lColLength<=100Calculate lPixels as 20End IfQuit method lPixelsYou are right that this is old Omnis classic mindset.If there is a way to replace the IF statement in my code, it will do me a great deal of good.Rgds,Martin.    On Saturday, July 2, 2022 at 08:32:47 PM GMT+3, Rob Mostyn <mostyn at> wrote:    H Martin,object oriented programming requires a complete mind shift from procedural (Omnis Classic) programming.   More than that, it is a multidimensional or rather multi layered mind shift.  This transition took me about 18 months to get some 20 years ago.  I am sure you are somewhere along the curve yourself but I/we cannot tell how far. My suggestion is that you focus on a class / subclass hierarchy to address, or at least partially address your challenge.  The solution will most likely be a combination of the two methods.Are your conditional statements implementing change in behaviour, change in business logic, change in presentation or change on … whatever?  To answer your question properly requires a good understanding of your code base which you have and we don’t, so Its difficult to answer your questions succinctly.Other may chip in with a more academic response.Cheers,RobOn 1 Jul 2022, at 20:45, Martin Obongita via omnisdev-en <omnisdev-en at> wrote:Hi Listers,I have an academic question about object-oriented programming.How is "polymorphism" implemented in Omnis Studio?I have many conditional statements in my code: if...else if, that keeps breaking whenever I make a change in a related method elsewhere.Is there a sample library in the HUB which best described how to work with code that can take many forms?Kind regards,Martin O._____________________________________________________________Manage your list subscriptions at https://lists.omnis-dev.comStart a new message -> mailto:omnisdev-en at   _____________________________________________________________Manage your list subscriptions at https://lists.omnis-dev.comStart a new message -> mailto:omnisdev-en at 

More information about the omnisdev-en mailing list