is there a limit to else if statements?

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

is there a limit to else if statements?

Postby bobm » Tue Jan 16, 2018 9:51 pm

I have a simple function that hides/shows specific elements (38) based on 38 possible different conditions, so a lengthy else if is needed. When I have 34 of these conditions running the program works fine in both Smart and Web clients.

When I add one more condition then the Smart Client errors (only in production NOT in developer) - the Web client works fine.
The error is "TypeError showDX is not a funtion, it is object."

The partial code below shows one of those conditions.
Code: Select all
function showDx(){

var a = VisionImpairmentDefinitions_OD;
var b = VisionImpairmentDefinitions_OS;
var msgOD = 'You have chosen an Unqualified Vision Loss in the Right Eye. You must select Category 0-Normal- or Category 9-Undetermined- for the Left Eye.'
var msgOS = 'You have chosen an Unqualified Vision Loss in the Left Eye. You must select Category 0-Normal- or Category 9-Undetermined- for the Right Eye.'

if (a == "1" & b == "0"){
      elements.H54511A.visible= true;
      elements.H54512A.visible=false;
      elements.H5452A1.visible=false;
      elements.H5452A2.visible=false;
      elements.H54413A.visible=false;
      elements.H54414A.visible=false;
      elements.H54415A.visible=false;
      elements.H5442A3.visible=false;
      elements.H5442A4.visible=false;
      elements.H5442A5.visible=false;
      elements.H542X11.visible=false;
      elements.H542X12.visible=false;
      elements.H542X21.visible=false;
      elements.H542X22.visible=false;
      elements.H541131.visible=false;
      elements.H541132.visible=false;
      elements.H541141.visible=false;
      elements.H541142.visible=false;
      elements.H541151.visible=false;
      elements.H541152.visible=false;
      elements.H541213.visible=false;
      elements.H541214.visible=false;
      elements.H541215.visible=false;
      elements.H541223.visible=false;
      elements.H541224.visible=false;
      elements.H541225.visible=false;
      elements.H540X33.visible=false;
      elements.H540X34.visible=false;
      elements.H540X35.visible=false;
      elements.H540X43.visible=false;
      elements.H540X44.visible=false;
      elements.H540X45.visible=false;
      elements.H540X53.visible=false;
      elements.H540X54.visible=false;
      elements.H540X55.visible=false;
      elements.H543.visible=false;
      elements.H5461.visible=false;
      elements.H5462.visible=false;

   }else if(a == "2" & b == "0"){  ... 


Thanks for the help,
Bob
Bob Mezzadri
EyeCOR By Nteon
bobm
 
Posts: 71
Joined: Thu Dec 29, 2011 8:24 pm

Re: is there a limit to else if statements?

Postby jcompagner » Wed Jan 17, 2018 2:38 pm

If it really is only a smart client problem when in production then it is very likely a compile problem
Because by default the smart client compiles the javascript into java classes. This sometimes fails in certain situations when something gets to complex

You can make your code less complex (divide it up) or disable the compile by pushing a system property (can be configured on the admin page): servoy.disableScriptCompile=true to the smart client
system.property.servoy.disableScriptCompile=true in the system.properties area on the admin page.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8086
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: is there a limit to else if statements?

Postby bobm » Wed Jan 17, 2018 3:10 pm

Thanks Johan,
I'll try that tonight.
Bob Mezzadri
EyeCOR By Nteon
bobm
 
Posts: 71
Joined: Thu Dec 29, 2011 8:24 pm


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 3 guests