SourceForge has been redesigned. Learn more.

Calculated field? Code?

  • Andy Bordei

    Andy Bordei - 2007-07-02

    I'm a Visual FoxPro programmer.
    In order to migrate some simple applications on Open Source I've found DataWeb very convenient and easy to use for final client especially for net usage. But it's lack of documentation here.
    Sorry for some (maybe) stupid questions:
    How I'm supposed to write the code? In which programming language?
    For example I have a table field named cnp which is Decimal(13).
    In another field named cnpcorr which must be binary i have to calculate if a formula applied to first 12 digits of cnp is equal with the 13rd digit of cnp (true or false - 1 or 0).
    How I have to do that?

    • Danilo Limatola Esterno


      for simple formula you can use Expression in define column. For example:

      c1 as Decimal(8,2)
      c2 as Decimal(8,2)
      c3 as Calculated

      in Expression of c3 setting c1+c2.

      For hard formula you must use the code written in java (light).
      you can declare 2 funtion:
      beforeSetValue(e){} this automatically called before a column setting value. Tipically used to check value.
      afterSetValue(e){} this automatically called after a column setting value.

      For your example you must define 2 Column:
      1) cnp as Decimal(13)
      2) cnpcorr as Yes-No

      after in code you must define:

          if (e.getColumnName().equals("cnp")){
              var cnp = e.getValue().toString();
              var s1 = cnp.substring(0,12);
              var s2 = cnp.substring(13);
              //HERE YOUR FORMULA. TO SET cnpcorr VALUE USE e.getTable().setValue("cnpcorr",true);

      if you connect in online demo ( i have create your sample in package Test, Table1, Form1.

      For any question please submit new post
      Danilo Limatola

    • Andy Bordei

      Andy Bordei - 2007-07-03

      Thank you very much.
      Now I have a direction regarding formulas and language. Let's start to work. :))
      I'm planing to develop an application for simplify office paperwork (to complete contracts on-the-fly at client office for example) based on a persons database, a database with companies (linked by where every person work) and a lot of standard business forms. Then the user have to choose the form, the persons or companies involved in that form and print or save as pdf.

      Continue the good work!

      Best regards,


Log in to post a comment.