WideStudio Logo
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
WSCvariant getProperty() get a value of the specified property
WSCvariant 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().

...
let event_procedure obj =

  (* To get a value of the property: "x" by string type. *)
  let x = obj -> getProperty ("x")
  in print_string( get_string x);
  print_newline();

  (* To get a value of the property: "y" by long type. *)
  let y = obj -> getProperty ("y")
  in print_int(get_int y);
  print_newline();

  ()
let _ = Callback.register "event_procedure" event_procedure

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 the value by short type. The method: getProperty() returns a value by WSCvariant type. The WSCvariant type can convert the various kinds of type automatically.

Methods of WSCvariant function
getChar() To get a value of char type.
getUnsignedChar() To get a value of unsigned char type.
getShort() To get a value of short type.
getUnsignedShort() To get a value of unsigned short type.
getLong() To get a value of long type.
getUnsignedLong() To get a value of unsigned long type.
getInt() To get a value of int type.
getUnsignedInt() To get a value of unsigned int type.
getFloat() To get a value of float type.
getDouble() To get a value of double type.
getCharPtr() To get a value of string type.



Setting of property

You can set a value to the property by the method of WSCbase::setProperty().

...
let event_procedure obj =

  (* To set a value to the property: "x" by string type. *)
  let x = "100"
  in obj -> setProperty ("x", (make_string x) );

  (* To set a value to the property: "y" by short type. *)
  let y = "100"
  in obj -> setProperty ("y", (make_int y) );

  ()
let _ = Callback.register "event_procedure" event_procedure

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.

...
let event_procedure obj =
  !obj1 -> setProperty ("labelString", "string1");
  !obj1 -> update()                             (* updates the instance *)
  _WSGIappDev'() -> "update" ();

  !obj2 -> setProperty ("labelString", "string2");
  !obj2 -> update()                             (* updates the instance *)
  _WSGIappDev'() -> update ();

  ()
let _ = Callback.register "event_procedure" event_procedure

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.80 for WideStudio ver 3.80, Jan 2005


WideStudio documents index | Table of contents

Copyright(C) WideStudio Development Team, 1999-2005 Last modified: Jan 05, 2005