Hello Donald.
You were very close. Since you were erroneously treating the ?hash-set
variable in the last statement in your (progn) as a function, to get the
result you want, remove the parentheses surround it, as in the following
very slightly modified form of you (defglobal):
(defglobal ?*usps-state-codes* = (progn
(bind ?hash-set (new java.util.HashSet 59))
(call ?hash-set add "AL") (call ?hash-set add "AK") (call ?hash-set
add "AS") (call ?hash-set add "AZ")
(call ?hash-set add "CA") (call ?hash-set add "CO") (call ?hash-set
add "CT") (call ?hash-set add "DE")
(call ?hash-set add "DC") (call ?hash-set add "FM") (call ?hash-set
add "FL") (call ?hash-set add "GA")
(call ?hash-set add "GU") (call ?hash-set add "HI") (call ?hash-set
add "ID") (call ?hash-set add "IL")
(call ?hash-set add "IN") (call ?hash-set add "IA") (call ?hash-set
add "KS") (call ?hash-set add "KY")
(call ?hash-set add "LA") (call ?hash-set add "ME") (call ?hash-set
add "MH") (call ?hash-set add "MD")
(call ?hash-set add "MA") (call ?hash-set add "MI") (call ?hash-set
add "MN") (call ?hash-set add "MS")
(call ?hash-set add "MO") (call ?hash-set add "MT") (call ?hash-set
add "NE") (call ?hash-set add "NV")
(call ?hash-set add "NH") (call ?hash-set add "NJ") (call ?hash-set
add "NM") (call ?hash-set add "NC")
(call ?hash-set add "ND") (call ?hash-set add "MP") (call ?hash-set
add "OH") (call ?hash-set add "OK")
(call ?hash-set add "OR") (call ?hash-set add "PW") (call ?hash-set
add "PA") (call ?hash-set add "PR")
(call ?hash-set add "RI") (call ?hash-set add "SC") (call ?hash-set
add "SD") (call ?hash-set add "TN")
(call ?hash-set add "TX") (call ?hash-set add "UT") (call ?hash-set
add "VT") (call ?hash-set add "VI")
(call ?hash-set add "VA") (call ?hash-set add "WA") (call ?hash-set
add "WV") (call ?hash-set add "WI")
(call ?hash-set add "WY")
?hash-set))
Getting the string value of the global java.util.HashSet variable shows
that this has worked:
> (string ?*usps-state-codes*)
"[VT, RI, HI, VI, MH, ME, VA, MI, DE, ID, IA, MD, MA, AS, UT, IL, IN,
MN, AZ, MP, MO, MT, MS, NH, PW, NJ, PR, NM, AK, AL, TX, NC, ND, NE, GA,
NV, TN, CA, OK, OH, WY, FM, FL, SD, SC, CT, WV, DC, WI, KY, KS, OR, LA,
GU, WA, CO, PA]"
Regards,
Win Carus
On 09/18/2010 09:24 AM, Donald Winston wrote:
Why doesn't this work?
(defglobal ?*usps-state-codes* = (progn
(bind ?hash-set (new java.util.HashSet 59))
(call ?hash-set add "AL") (call ?hash-set add "AK") (call
?hash-set add "AS") (call ?hash-set add "AZ")
(call ?hash-set add "CA") (call ?hash-set add "CO") (call
?hash-set add "CT") (call ?hash-set add "DE")
(call ?hash-set add "DC") (call ?hash-set add "FM") (call
?hash-set add "FL") (call ?hash-set add "GA")
(call ?hash-set add "GU") (call ?hash-set add "HI") (call
?hash-set add "ID") (call ?hash-set add "IL")
(call ?hash-set add "IN") (call ?hash-set add "IA") (call
?hash-set add "KS") (call ?hash-set add "KY")
(call ?hash-set add "LA") (call ?hash-set add "ME") (call
?hash-set add "MH") (call ?hash-set add "MD")
(call ?hash-set add "MA") (call ?hash-set add "MI") (call
?hash-set add "MN") (call ?hash-set add "MS")
(call ?hash-set add "MO") (call ?hash-set add "MT") (call
?hash-set add "NE") (call ?hash-set add "NV")
(call ?hash-set add "NH") (call ?hash-set add "NJ") (call
?hash-set add "NM") (call ?hash-set add "NC")
(call ?hash-set add "ND") (call ?hash-set add "MP") (call
?hash-set add "OH") (call ?hash-set add "OK")
(call ?hash-set add "OR") (call ?hash-set add "PW") (call
?hash-set add "PA") (call ?hash-set add "PR")
(call ?hash-set add "RI") (call ?hash-set add "SC") (call
?hash-set add "SD") (call ?hash-set add "TN")
(call ?hash-set add "TX") (call ?hash-set add "UT") (call
?hash-set add "VT") (call ?hash-set add "VI")
(call ?hash-set add "VA") (call ?hash-set add "WA") (call
?hash-set add "WV") (call ?hash-set add "WI")
(call ?hash-set add "WY")
(?hash-set)))
(printout t (call ?*usps-state-codes* contains "VA") crlf)
I need to have a global variable that will contain state code values
after a (reset). list "AL" "AK" ... works but a HashSet would be more
efficient. A jess list is not a collection so I can't use the
HashSet(Collection) constructor.
begin:vcard
fn:Win Carus
n:Carus;Win
org:Information Extraction Systems, Inc. (tm)
adr:;;20 East Quinobequin Road;Waban;MA;02468;USA
email;internet:win.ca...@infoextract.com
title:President
tel;work:(617) 244-5068
tel;fax:(617) 244-5068
note;quoted-printable:=E2=80=9CInformation Extraction Systems=E2=80=9D,
=E2=80=9CInfoExtract=E2=
=80=9D, and =E2=80=9CIEBuilder=E2=80=9D are trademarks or registered
trad=
emarks owned by Information Extraction Systems, Inc.
x-mozilla-html:FALSE
url:http://www.InfoExtract.com
version:2.1
end:vcard