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
>

See Also

Functions - Alphabetical Listing