USE Verb

Syntax

USE java.<class>.<name>

USE ::<filename>::<bbjclassname>

Description

The USE verb enables a BBj program to reference a BBj Custom Object class defined in another program file or to reference a Java class without having to specify the full package name of the class for each reference.

Parameter

Description

java.class.name

The complete name of a Java class, including the full package name (e.g. java.util.HashMap).

filename

The path to a file that contains the BBj Custom Object class definition. BBj locates this file using its normal file resolution procedures, checking the current working directory and prefix.

bbjclassname

The name of a BBj Custom Object class defined in the specified file.

Notes

The USE verb must be the only statement on the line (with one exception: it can end with a ; REM comment).

For information on specifying a USE directive in a configuration file, see the USE section of The config.bbx Configuration File - BBj.

Examples

The following example consists of two separate files: use.bbj, which demonstrates USE statements and is runnable as a BBj program, and payroll.bbj, which contains custom classes that are used by use.bbj.

rem ' use.bbj

use java.util.HashMap
use ::payroll.bbj::Salaried
use ::payroll.bbj::Hourly

map! = new HashMap()
map!.put(1,"Mary Jones")
map!.put(2,"John Smith")

e1! = new Salaried()
e1!.setID(1)
e1!.setName(map!.get(e1!.getID()))
e1!.setMonthlySalary(5000)
e1!.print()
print "GL Account:",e1!.account()

e2! = new Hourly()
e2!.setID(2)
e2!.setName(map!.get(e2!.getID()))
e2!.setHourlyRate(15)
e2!.setHoursWorked(168)
e2!.print()
print "GL Account:",e2!.account()
rem ' payroll.bbj

interface public Address
    method public void address()
interfaceend

interface public Pay
    method public void print()
interfaceend

interface public GL
    method public BBjNumber account()
interfaceend

interface public Payable extends Pay, GL
    method public BBjNumber pay()
interfaceend

class public Employee
    field public BBjNumber ID
    field public BBjString Name$
classend

class public Salaried extends Employee implements Payable
    field public BBjNumber MonthlySalary

    method public BBjNumber pay()
        methodret #MonthlySalary
    methodend

    method public void print()
        print "Employee",#getID(),": ",#getName()
        print #pay():"($###,###.00)"
    methodend

    method public BBjNumber account()
        methodret 11111
    methodend

classend

class public Hourly extends Employee implements Payable
    field public BBjNumber HourlyRate
    field public BBjNumber HoursWorked

    method public BBjNumber pay()
        methodret #HourlyRate*#HoursWorked
    methodend

    method public void print()
        print "Employee",#getID(),": ",#getName()
        print #pay():"($###,###.00)"
    methodend

    method public BBjNumber account()
        methodret 22222
    methodend

classend

See Also

Verbs - Alphabetical Listing