0 Replies Latest reply: Jul 24, 2008 11:47 AM by 843833 RSS

    Use of functions in static block

    843833
      Hello,

      I have this app containing a static {} block. The reason it's there is to 1) provide a splash screen 2) have input dialog to process input string and check if it's valid in order to load app or not.

      In pseudocode it's like this:

      1 - get input string with showInputDialog()
      2 - check for the input string validity (a valid string is with prefix A-, C- or S-)
      3 - if string is valid, load the app
      4 - if string is not valid, proceed to step 1.


      As you may already see, there is going to be a lot of code (with if-else statements) to check for A-, C- and S- prefixed because I am using indexOf() function which takes only one parameter.

      I am considering a way to somehow check recursively, but for this I think I'll need a function to call indexOf() with A-, C-, S- and assess validity for each case.

      My question is, is there a way in the static block to have a function? Or can somebody please recommend an efficient approach to checking a string validity with different possibilities inside a static block as in my case, to avoid lots of if-else statements?


      Thank you!
      Victor.