BBjFileInfo::addKey

Description

In BBj 6.00 and higher, this method adds a new key chain to a VKEYED file.

Syntax

Return Value

Method

void

addKey(int keynum, BBjKeyInfo keyinfo)

void

addKey(string keyname, BBjKeyInfo keyinfo)

Parameters

Variable

Description

keynum

Specifies the key number where the new key chain will be inserted.

keyname

Specifies the key name to be added to the end of the list.

BBjKeyInfo

The key structure of the new key chain.

Return Value

None.

Remarks

This method will fail, reporting an !ERROR=13 if any of the following conditions is true:

  •  The file is not VKEYED

  •  The file is not locked

  •  Attempt to insert a key number past the end of the list

This method will fail, reporting an !ERROR=11 on an attempt to add a named key chain that already exists.

Example

rem ' Adds a new key chain to a VKEYED file

filename$ = "Sample.dat"
erase filename$,err=*next
vkeyed filename$,[1:1:6]+[2:1:3],[3:1:2:"U"],0,64
channel = unt
open (channel)filename$
BBjFileSystem! = BBjAPI().getFileSystem()
BBjFileInfo! = BBjFileSystem!.getFileInfo(channel)
print "Insert a new key chain at knum = 1"
BBjKeySegment! = BBjFileSystem!.makeKeySegment(4,0,8,1,1)
BBjKeyInfo! = BBjFileSystem!.makeKeyInfo(BBjKeySegment!,0)
BBjFileInfo!.lock()
BBjFileInfo!.addKey(1,BBjKeyInfo!)
BBjFileInfo!.unlock()
print "getKeyInfo(1) now reports: ",
print BBjFileInfo!.getKeyInfo(1)
print "Add a named key chain to the end"
BBjKeySegment! = BBjFileSystem!.makeKeySegment(5,0,6,0,0)
BBjKeyInfo! = BBjFileSystem!.makeKeyInfo(BBjKeySegment!,0)
BBjFileInfo!.lock()
BBjFileInfo!.addKey("New",BBjKeyInfo!)
BBjFileInfo!.unlock()
print "getKeyInfo('New') reports: ",
print BBjFileInfo!.getKeyInfo("New")
end

See Also

BBjAPI

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