BBjAPI::getGlobalNamespace

Description

In BBj 3.0 and higher, this method retrieves a BBjNamespace.

Syntax

Return Value

Method

BBjNamespace

getGlobalNamespace()

Parameters

None.

Return Value

Returns a BBjNamespace that refers to the persistent global Namespace.

Remarks

The global Namespace is accessible to any BBjProcess. It should be used with care because any BBjProcess can modify it. The global Namespace is unique in that it persists, even if there are no processes that have references to it.

The globalNamespace will continue to exist until BBjServices is restarted.

The method getGlobal Namespace() provides a mechanism by which all BBj Processes may share data and communicate with all running BBjProcesses.

Example

sysgui=unt
open (sysgui)"X0"
api! = BBjAPI()
sysgui!=api!.getSysGui()


REM retrieve a namespace, get value of count

switch argc
     case 1
          REM run from command line with no namespace name
          prefix$ = "basis.eng.test.namespace"
          sharedNSName$ = "test"
          sharedNS! = api!.getNamespace(prefix$, sharedNSName$, 1)
          break

     case 2
          REM run from command line with a namespace name
          prefix$ = argv(1)
          sharedNSName$ = "test"
          sharedNS! = api!.getNamespace(prefix$, sharedNSName$, 1)
          break

     case 3
          REM run from within MDI
          prefix$ = "basis.eng.test"
          sharedNSName$ = argv(1)
          sharedNS! = api!.getExistingNamespace(sharedNSName$)
          break

swend

count = sharedNS!.getValue("count", err=setCount)
privateNS! = api!.getNewNamespace(prefix$)
privateNS!.setValue("count",0)
name$ = "client-" + privateNS!.getName()

REM
REM retrieve position
REM

x = sharedNS!.getValue("x", err = setXY)
y = sharedNS!.getValue("y", err = setXY)

REM
REM increment position
REM

sharedNS!.setValue("x", x+50)
sharedNS!.setValue("y", y+50)

REM
REM create window
REM


window! = sysgui!.addWindow(x,y,300,200,name$)
plus! = window!.addButton(1,5,10,90,30,"Increment")
minus! = window!.addButton(2,105,10,90,30,"Decrement")
window!.addStaticText(101,5,50,290,30,"sharedCount:   ")
window!.addStaticText(102,5,70,290,30,"privateCount: ")
sharedCount! = window!.addStaticText(103,200,50,290,15,str(count))
privateCount! = window!.addStaticText(104,200,70,290,15,str(0))


break! = window!.addButton(3,5,110,90,30,"Break")
break!.setCallback(break!.ON_BUTTON_PUSH,"onBreak")


REM
REM set callback for controls
REM
plus!.setCallback(plus!.ON_BUTTON_PUSH, "onPlus")
minus!.setCallback(plus!.ON_BUTTON_PUSH, "onMinus")
window!.setCallback(window!.ON_ACTIVATE, "onActivate")

REM set callback that is to be called when count changes
sharedNS!.setCallbackForVariable("count", "showCount")
privateNS!.setCallbackForVariable("count", "showCount")

REM call onActivate to set tell others we have activated
gosub onActivate

callback(ON_CLOSE,done,sysgui!.getContext())

process_events

onPlus:
sharedNS!.setValue("count", 1 + sharedNS!.getValue("count"))
privateNS!.setValue("count", 1 + privateNS!.getValue("count"))
return


onMinus:
sharedNS!.setValue("count", -1 + sharedNS!.getValue("count"))
privateNS!.setValue("count", -1 + privateNS!.getValue("count"))
count = count - 1
return

onActivate:
print "onActivate called"
sharedNS!.setValue("activeClientNS", privateNS!.getName())
sharedNS!.setValue("activeClientName",name$)
return

showCount:
sharedcount!.setText(str(sharedNS!.getValue("count")))
privatecount!.setText(str(privateNS!.getValue("count")))
return

onBreak:
escape
return


done:
release

setXY:
x = 100
y = 100
sharedNS!.setValue("x", x)
sharedNS!.setValue("y", y)
retry

setCount:
count = 0
sharedNS!.setValue("count", count)
retry

See Also

BBjAPI

Object Variables

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.