| WideStudio Programming Guide | WideStudio Index Table of contents

> ## How to access a value of the property of the instance

> In the event program, you can access the property of the instance by the method: get/setProperty().

> the access method | Description
> mpfc::WSCvariant mpfc::WSCbase_getProperty() | get a value of the specified property
> mpfc::WSCvariant mpfc::WSCbase_setProperty() | set a value to the specified property

> ### How to get a value of the properties

> You can get a value of the property by the method of WSCbase: getProperty().

>     #----------------------------------------------------------
>     #Function for the event procedure
>     #----------------------------------------------------------
>     use mpfc;

>     sub event_procedure {
>             my ($object) = @_;

>         # To get a value of the property: "x" by string type.
>         $x = $object->getProperty("x");
>         printf("x=%s\n",$x->getCharPtr());

>         # To get a value of the property: "y" by long type.
>         $y = $object->getProperty("y");
>         printf("y=%d\n",$y->getLong());
>     }
>     1;

> In the example of "x", it gets a value by string type. The WSCstring type manages the buffer of the string automatically, so there is no need to manage it by programmer.
> In the example of "y", it gets a value by short type. The method: getProperty() returns a value by WSCvariant type. The WSCvariant type can convert the various kind of type automatically.

> Methods of mpfc.SCvariant | function
> mpfc::WSCvariant_getChar() | To get a value of char type.
> mpfc::WSCvariant_getUnsignedChar() | To get a value of unsigned char type.
> mpfc::WSCvariant_getShort() | To get a value of short type.
> mpfc::WSCvariant_getUnsignedShort() | To get a value of unsigned short type.
> mpfc::WSCvariant_getLong() | To get a value of long type.
> mpfc::WSCvariant_getUnsignedLong() | To get a value of unsigned long type.
> mpfc::WSCvariant_getInt() | To get a value of int type.
> mpfc::WSCvariant_getUnsignedInt() | To get a value of unsigned int type.
> mpfc::WSCvariant_getFloat() | To get a value of float type.
> mpfc::WSCvariant_getDouble() | To get a value of double type.
> mpfc::WSCvariant_getCharPtr() | To get a value of string type.

> ### Setting of property

> You can set a value to the property by the method of mpfc::WSCbase_setProperty().

>     #----------------------------------------------------------
>     #Function for the event procedure
>     #----------------------------------------------------------
>     use mpfc;

>     sub event_procedure {
>             my ($object) = @_;

>         # To set a value to the property: "x" by string type.
>         $x="100";
>         $object->setProperty("x",$x);

>         # To set a value to the property: "y" by short type.
>         $y=100;
>         $object->setProperty("y",$y);
>         return;
>     }
>     1;

> In the example of "x", it sets a value by string type. In the example of "y", it sets a value by short type. The parameter of the method: setProperty() is WSCvariant type, so it converts the value automatically.

> ### Updating the instance to reflect the changed value

> Use the method: update(),draw(),redraw() to update the instance to reflect the changed value.

>     #----------------------------------------------------------
>     #Function for the event procedure
>     #----------------------------------------------------------
>     use mpfc;

>     sub event_procedure {
>       my ($object) = @_;

>       $newvlab_001->setProperty("labelString","string1");
>       $newvlab_001->update();   # updates the instance
>       mpfc::WSGIappDev()->update();

>       $newvlab_002->setProperty("labelString","string2");
>       $newvlab_002->update();    # updates the instance
>       mpfc::WSGIappDev()->update();
>       return;
>     }
>     1;

> Usually, it updates automatically when the event procedure is done, but if you want to update right away,you can use the method: update(),draw(),redraw().
> The method: update() or draw() updates the instance if needed, but redraw() updates compulsory.

Document Release 3.70 for WideStudio ver 3.70, May 2004

WideStudio documents index | Table of contents

Copyright(C) WideStudio Development Team, 1999-2004 | Last modified: May 25, 2004