How create objects in top_object()

Document created by Daniel Becker Bighelini on Feb 20, 2017
Version 1Show Document
  • View in full screen mode

Now it is very easy to program in the SPEL language by declaring objects instead of using arrays. Here is an example code:

 

void z_myMethod()
{
    object zo_obj;
    zo_obj = z_createObject('name', 'daniel', 'age', 39, 'birthday', now());

    printf("Object: '%s'\n", (string) zo_obj);
    printf("# '%s'\n", zo_obj.name);
    printf("# '%s'\n", zo_obj.age);
    printf("# '%s'\n", zo_obj.birthday);
}


object z_createObject(...)
{
    // Create a object in top_object() context
    // The parameters may be informed in paires

 

    ///////////////////////////////////////////////////////////////////////////////////////
    // Begin
    int zi_i;
    for (zi_i=0; zi_i<argc; zi_i+=2) {
        send_wait(0, this, "call_attr", argv[zi_i], "set_val", argv[zi_i+1]);
    }
    return this;
    // Finish
    ///////////////////////////////////////////////////////////////////////////////////////
}

3 people found this helpful

Attachments

    Outcomes