Announcement

Collapse
No announcement yet.

PluriBASIC - Conditional #IF statement for form output.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PluriBASIC - Conditional #IF statement for form output.


    Last night I implemented a new feature that will make things easier for working with PHP (for the moment, other platform implementations are planned to follow). I wanted this feature for a long time and i finally added it. This feature is #IF statement support for HTML support.

    So far, the #IF statement was implemented for source code generation (in the binaries), source code compilation (in the main code) and now it is implemented also for HTML code.

    Now you can add #IF statements in your HTML chunks and FORMOUT() will output the code depending on the conditions and the run-time variables.

    For example, lets say you have a form like this:
    Code:
    #FORM Conditionals, "conditionals.html"
    And the conditionals.html file contains this HTML code:
    Code:
    #IF Cfg.values = "This is cool"
        <div>First block, [$.cool].</div>
    #ELSEIF SecondBlock
        <div>Second block, [$.cool].</div>
    #ELSE
        <div>Third block, [$.cool].</div>
    #ENDIF
    Then you have an HTML form that will be sent to the browser depending on what these variables contain at run time. For example:
    Code:
    ' Declares some variables.
    Local SecondBlock as long
    Local Cfg as Config
    
    ' Sets up some variables at run-time.
    Cfg.values = "This is cool"
    SecondBlock = 2
    $.cool = "This feature is a time saver"
    
    ' Outputs the form according to that the variables contain.
    CALL FORMOUT(Conditionals)
    This would be the output:
    Code:
    First block, This feature is a time saver.
    Lets say you change the variable Cfg.values to:
    Code:
    Cfg.values = "This is too cool"
    Then the HTML output would be:
    Code:
    Second block, This feature is a time saver.
    Finally lets say we change he variable SecondBlock to:
    Code:
    SecondBlock = 0
    The HTML output would be:
    Code:
    Third block, This feature is a time saver.
    This feature saves time and allows to have multiple scenarios of the code without the need of embedding multiple forms and concatenating them manually. Just one variable and the apropriate portion of code can be displayed. The displayed portions of code, of course, can embed other HTML portions or different portions of Javascript code. This allows to focus on what you are doing, instead of how you are doing it.

    This version of PluriBASIC is not uploaded, if you like this feature you can send me an email to get it.


    www.pluribasic.com
    www.patreon.com/pluribasic
Working...
X