Home > lang > createstatic 
 en fr de es it nl pl pt pt_BR mk sq ca hu cs tr ar fa id vi ko ja ru zh zh_TW
Previous  Next  Edit  Rename  Undo  Search  Administration  
Documentation  
Warning! This page is not translated.  See english version 
CREATE STATIC
CREATE STATIC

These keywords, when placed alone at the beginning of a class file, tells the interpreter that when applying non-static symbols to the name of the class, an automatic hidden instance of it will be created on the fly.

This feature allows you to implement the object-oriented programming singleton pattern.

If you use this feature, the class constructor (the special method _new) will be called with no parameters.

This feature is already used internally by the Form and the Settings classes.

Here are the first 13 lines (are you superstitious?) of the Settings class code:

Example

' Gambas class file
EXPORT
CREATE STATIC

PRIVATE $sPath AS String
PRIVATE $sTitle AS String
PRIVATE $cSlot AS NEW Collection
PRIVATE $bModify AS Boolean

PUBLIC SUB _new(OPTIONAL Path AS String, OPTIONAL Title AS String)

  DIM hFile AS File
  DIM sLine AS String
...

See also

Object & Class Management, CREATE PRIVATE