Announcement

Collapse
No announcement yet.

How to use own PHP class - help needed - urgent

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

  • How to use own PHP class - help needed - urgent

    Hi Guys,

    I would like to use external library wrote by me.
    Could you please help to include it?

    class is simple, with constructor:

    PHP Code:

    class MyClass {

        public 
    $something;

        function 
    __contruct($var) {
           
    $this->something $var;
        }

        function 
    setSomething() {
           return 
    $this->something;
        }




    I would like to use it in Form's AjaxEvent:

    PHP Code:
    AjaxEvent -> field_onChange

    $c 
    = new MyClass("123");
    {
    field} = $c->setSomething
    When I trying to run Form, i have an error:

    Parse error: syntax error, unexpected '$c' (T_VARIABLE) in C:\Program Files\NetMake........ (long path to Form.apl.php)

    What I do:

    1. SC8 > Tools > Libraries > i added MyClass.class.php in "Public"
    2. I assigned MyClass.class.php in Form > Programming > Libraries

    but propably something is wrong, maybe I don't understand how to do it correctly.

    Please help.
    Thank you,

    daretzki (Darek)

  • #2
    Hi, i have a script and it worked.


    If you wish use the class global example in login you must:
    ----------------------------------------------
    - Programming / Library / mark class name for include

    - In event onvalidatesuccess, initialize variable global for class

    [test] = serialize(new myclass());


    In a event of a form
    -----------------------------------------------------------

    $clase = unserialize([test]);
    $valor = $clase->SetCol(2);
    [test] = serialize($clase);


    De esta forma se hace uso de la clase
    ================================================== ===========

    using the class
    -----------------
    $global = unserialize([global_class]);
    $banco = $global->getBanco();

    if(({lvd_tpoentrda} == $banco) && (!{BAN_CDGO} > 0)) {
    // sc_error_message("Por favor especifique el banco");
    sc_error_message("text malo");
    }
    -------------------

    Comment


    • #3
      Thank you.

      But i need use it in AjaxEvents not in Form Events. I am looking for good example how to do it.

      Comment


      • #4
        [SOLVED] How to use own PHP class - help needed - urgent

        Hi again,

        my false! Broken "-" sign in one row.

        nr_konta_onChange (Ajax Events)

        before:

        PHP Code:

        if (empty({nr_konta}))
        {
            {
        nr_konta} = "37114020040000310242321556";
        } else {
            
        /* class initialization below */
                
        $n = new NRB({nr_konta});
                
        /* --- */
            
        if ($n->poprawny()) {
                {
        nr_konta} = $n->formatuj();
                 {
        nazwa_banku}  $n->dekodujNazwe(); <--------- error there
             
        } else {
                {
        nr_konta} = ''
                 {
        nazwa_banku} = "\n$n->blad: ".$n->formatuj();
             }

        after:

        PHP Code:

        if (empty({nr_konta}))
        {
            {
        nr_konta} = "37114020040000310242321556";
        } else {
            
        $n = new NRB({nr_konta});
            if (
        $n->poprawny()) {
                {
        nr_konta} = $n->formatuj();
                 {
        nazwa_banku} = $n->dekodujNazwe();   <-------- corrected
             
        } else {
                {
        nr_konta} = ''
                 {
        nazwa_banku} = "\n$n->blad: ".$n->formatuj();
             }

        Sorry.
        I will write short HOW-TO use classes in SC soon.

        daretzki

        Comment


        • #5
          you promised - right ?
          so where is it ?
          -----------------------------------------
          Arthur Klisiewicz
          dATA POINT SOFTWARE
          www.datapointsoftware.com

          Comment

          Working...
          X