BBjNamespace::getValue

Description

In BBj 3.0 and higher, this method returns the value for the named BBjNamespace object.

Syntax

Return Value

Method

BBjObject

getValue(string name)

Parameters

Variable

Description

name

Specifies the named object for which the value is to be retrieved.

Return Value

Returns the requested object

Remarks

If the requested named object is not in the BBjNamespace, then this method generates an !ERROR=63 - Uninitialized Variable.

Example

rem namespace.bbj

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

REM retrieve a namespace, get value of count

if api!.isInMDI()
     sharedNS! = api!.getGroupNamespace()
     prefix$ = "basis.eng.test.namespace"
else
     if argc < 2
          REM run from command line with no namespace name
          prefix$ = "basis.eng.test.namespace"
          sharedNSName$ = "test"
          sharedNS! = api!.getNamespace(prefix$, sharedNSName$, 1)

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

REM retrieve count from sharedNS! and use it to create our name
     count = sharedNS!.getValue("count", err=setCount)
     privateNS! = api!.getNewNamespace(prefix$)
     privateNS!.setValue("count",0)
     name$ = "client-" + privateNS!.getName()

REM retrieve position from sharedNS! and increment it
     sharedNS!.setLock("x", 500, err = onLocked)
     x = sharedNS!.getValue("x", err = setXY)
     sharedNS!.setValue("x", x+50)
     sharedNS!.removeLock()

     sharedNS!.setLock("y", 500, err = onLocked)
     y = sharedNS!.getValue("y", err = setXY)
     sharedNS!.setValue("y", y+50)
     sharedNS!.removeLock()

REM create window
     window! = sysgui!.addWindow(x,y,300,200,name$)

REM add some static text fields
     window!.addStaticText(101,5,50,290,30,"sharedCount:   ")
     window!.addStaticText(102,5,70,290,30,"privateCount: ")

REM add buttons and callbacks
     plus! = window!.addButton(1,5,10,90,30,"Increment")
minus! = window!.addButton(2,105,10,90,30,"Decrement")
break! = window!.addButton(3,5,110,90,30,"Break")

     sharedCount! = window!.addStaticText(103,200,50,290,15,str(count))
     privateCount! = window!.addStaticText(104,200,70,290,15,str(0))
     break!.setCallback(break!.ON_BUTTON_PUSH,"onBreak")



REM set callback for controls
     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())

REM if running in MDI, register a callback for MDI closing

if api!.isInMDI()
     mdi! = api!.getMDI()
     mdi!.registerMDIClosingCallback("mdiClosingCallback")
endif


process_events

REM our callbacks
onPlus:
     sharedNS!.setLock("count",1500,err = onLocked)
   sharedNS!.setValue("count", 1 + sharedNS!.getValue("count"))
     sharedNS!.removeLock()

     privateNS!.setLock("count",1500,err = onLocked)
     privateNS!.setValue("count", 1 + privateNS!.getValue("count"))
     privateNS!.removeLock()
return


onMinus:
     sharedNS!.setLock("count",1500,err = onLocked)
     sharedNS!.setValue("count", -1 + sharedNS!.getValue("count"))
     sharedNS!.removeLock()

     privateNS!.setLock("count",1500,err = onLocked)
     privateNS!.setValue("count", -1 + privateNS!.getValue("count"))
     privateNS!.removeLock()
return


onActivate:
     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

onLocked:
     print "lock error"
     escape
retry
m
REM callback to be run when MDI attempts to close
mdiClosingCallback:
     print 'EE', 'ask'("MDI is attempting to close",3,"What do you want to do?","Veto close:1","Accept close:2","Release:3")

print 'BE'

     read(0,siz=1,err=askCancelled)response
     print "answer is " , response
     print 'BE'

     switch response
     case 1
          mdi!.vetoMDIClose()
          break
     case 2
          mdi!.approveMDIClose()
          break
     case 3
          gosub done
          break
     swend
return

askCancelled:
print "ask was cancelled or else closeAll() timed out"
mdi!.approveMDIClose(err=*next)
return

See Also

BBjAPI

BBjNamespace

Object Variables

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