NULL() Function - Return Java Null Value


Syntax

NULL()

Description

The NULL() function returns a Java null value. It is typically used to check for a null value returned from a Java function.

Example

REM ' demonstrate use of the null() function

REM ' create a HashMap object
LET state!=new java.util.HashMap()

loop: REM ' Load the HashMap with state codes and names
DREAD code$,name$,END=test
state!.put(code$,name$)
GOTO loop

test: REM ' Prompt for state code; retrieve the name
INPUT "State code?",code$
LET code$=CVS(code$,7)
IF code$="" THEN STOP

REM ' retrieve to an object variable because null()
REM ' cannot be stored to a string variable
LET name!=state!.get(code$)

REM ' null() return value indicates the code wasn't found
IF name!=NULL() THEN PRINT "Unknown state code"
IF name!<>NULL() THEN PRINT "State name is ",name!
GOTO test

DATA "AK","Alaska"
DATA "AL","Alabama"
DATA "AR","Arkansas"
DATA "AZ","Arizona"
DATA "CA","California"
DATA "CO","Colorado"
DATA "CT","Connecticut"
DATA "DC","District of Columbia"
DATA "DE","Delaware"
DATA "FL","Florida"
DATA "GA","Georgia"
DATA "GU","Guam"
DATA "HI","Hawaii"
DATA "IA","Iowa"
DATA "ID","Idaho"
DATA "IL","Illinois"
DATA "IN","Indiana"
DATA "KS","Kansas"
DATA "KY","Kentucky"
DATA "LA","Louisiana"
DATA "MA","Massachusetts"
DATA "MD","Maryland"
DATA "ME","Maine"
DATA "MI","Michigan"
DATA "MN","Minnesota"
DATA "MO","Missouri"
DATA "MS","Mississippi"
DATA "MT","Montana"
DATA "NC","North Carolina"
DATA "ND","North Dakota"
DATA "NE","Nebraska"
DATA "NH","New Hampshire"
DATA "NJ","New Jersey"
DATA "NM","New Mexico"
DATA "NV","Nevada"
DATA "NY","New York"
DATA "OH","Ohio"
DATA "OK","Oklahoma"
DATA "OR","Oregon"
DATA "PA","Pennsylvania"
DATA "PR","Puerto Rico"
DATA "RI","Rhode Island"
DATA "SC","South Carolina"
DATA "SD","South Dakota"
DATA "TN","Tennessee"
DATA "TX","Texas"
DATA "UT","Utah"
DATA "VA","Virginia"
DATA "VI","Virgin Islands"
DATA "VT","Vermont"
DATA "WA","Washington"
DATA "WI","Wisconsin"
DATA "WV","West Virginia"
DATA "WY","Wyoming"

>RUN
State code?nm       
State name is New Mexico
State code?ny
State name is New York
State code?xx
Unknown state code
State code?

READY
>



______________________________________________________________________________________

Copyright BASIS International Ltd. BBj®, Visual PRO/5®, PRO/5®, and BBx® are registered trademarks.