Hi Jason, Thanks for the detailed mail.
Cheers, Hari Jason Morris wrote: > >> What string and date operations does Jess support? >> I saw a str-cat operator, is there some for "string compare", "like" or > "in" >> something like these?> How do I define conditions for date operations? > Like date less than current >> date or so? >> Where can I find more information on the available string/date >> operations. > > Hi Nara, > > Your questions fall under the heading of "manipulating Java objects from > Jess", so it's good to review that chapter in the documentation before you > proceed with my suggestions. Check out: > http://herzberg.ca.sandia.gov/jess/docs/70/java.html# <-- this # might > not > be included in so cut and paste the URL. > > Next, bookmark this page if you have not already :-) > http://herzberg.ca.sandia.gov/jess/docs/70/function_index.html > > Near the bottom, you will see that Jess supports the following string > functions: > > asc, lowcase, regexp, str-cat, str-compare, str-index, str-length, > sub-string, sym-cat, upcase > > > Many new Jess users overlook that everything that you have available to > you > in Java proper you also have available to you through Jess. Therefore, > you > could write something like: > > (bind ?mystring "over the hills and far away") > > and then use any of the methods of java.lang.String i.e. > > (bind ?tokens (?mystring split " ")) ; Using String.split(" ") > > which Jess will massage into its preferred list structure rather than a > String array. > You could then use this list like: > > (foreach ?token ?tokens > (printout t "token=" ?token crlf)) > > and Jess will print out: > > token=over > token=the > token=hills > token=and > token=far > token=away > > As for Dates, the same principle applies: Jess simply uses the Java > objects > for dates and times, which are largely centered around the > java.util.Calendar class now. You could do something like this: > > ; Jess script snippet > (import java.util.Locale) > (import java.util.Calendar) > (bind ?locale (new Locale Locale.ENGLISH Locale.US)) > (bind ?calendar (call Calendar getInstance ?locale)) > > Once you have a Calendar object, see these pages for all the things you > can > do with it. > Again, this really isn't special, it's just how the Jess language works > with Java proper. > http://java.sun.com/j2se/1.4.2/docs/api/java/util/Calendar.html > http://java.sun.com/j2se/1.4.2/docs/api/java/util/GregorianCalendar.html > > As for your question about "one date less than another" and so forth, note > that java.util.Date implements java.lang.Comparable, so you have a whole > bunch of ways to compare two Date objects. > http://java.sun.com/j2se/1.4.2/docs/api/java/util/Date.html > > You will want to see George Williamson's excellent notes on the Jess Wiki > as > well. > http://herzberg.ca.sandia.gov/jesswiki/view?WorkingWithDates > > So, the basic formula is: > 1. Get familiar with how to manipulate any Java object from Jess. > 2. Look up the API that you want to use and figure out what methods you > need > to use. > 3. Convert the pure Java API to the corresponding Jess language syntax > (list-based). > 4. Rinse and repeat as necessary. ;-) > > Hope this helps! > Cheers, > Jason > ----------------------------------------------------------- > Jason C. Morris > Worcester Polytechnic Institute Phone: (508) 831-5006 > Department of Computer Science FAX: (508) 831-5776 > Fuller Laboratories - Room 312 [EMAIL PROTECTED] > Artificial Intelligence Lab (AIRG) > 100 Institute Road > Worcester, MA 01609-2280 > ----------------------------------------------------------- > > -- View this message in context: http://www.nabble.com/String-and-Date-operations-tf3868149.html#a10973399 Sent from the Jess mailing list archive at Nabble.com. -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] --------------------------------------------------------------------