🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: a.testing.group
Article #147

Re: [newbie] my first FORTH program

#147
From: KezL
Date: Sat, 19 Jun 2010 20:00
86 lines
3982 bytes
Hi Everyone,

Thanks for all the comments.
I have modified the code to address some of them.
( some were too advanced for me at this stage )

More comments welcome!

Thank you,

KezL

\ CHATTERBOX PROGRAM WITH A MOOD SETTING
\ INTERACTING WITH IT CHANGES THE MOOD
\ AND GIVES OUTPUT DEPENDING ON MOOD
\ AND INPUT. USES NON-STANDARD WORD ,"

0 CONSTANT HAPPY
1 CONSTANT SAD
2 CONSTANT BORED
3 CONSTANT ANGRY

0 CONSTANT INSULT
1 CONSTANT FLATTER
2 CONSTANT BORE
3 CONSTANT AMUSE

\ NEWSTATES: STATE TRANSITION TABLE 4 X 4 X 1 CELLS
\ Current Mood: HAPPY SAD BORED ANGRY
                                                                             
                  \ INPUT:
CREATE NEWSTATES  ANGRY , SAD ,  SAD ,  ANGRY , \ INSULT ME
           HAPPY , HAPPY , SAD ,  BORED , \ FLATTER ME
           BORED , SAD ,  BORED , ANGRY , \ BORE ME
           HAPPY , HAPPY , ANGRY , BORED , \ AMUSE ME

\ COMMENTS: OUTPUT TABLE 4 X 4 X 40 BYTES
CREATE COMMENTS  ," I DON'T LIKE YOU ANY MORE!             "
   ," KICK ME WHEN I'M DOWN THEN YOU FIEND!  "
   ," LEAVE ME ALONE!                        "
   ," GO TO HECK!                            "
   ," THANK YOU                              "
   ," I FEEL BETTER NOW                      "
   ," I KNOW YOU DON'T MEAN IT               "
   ," YEAH RIGHT WHATEVER                    "
   ," YAWN                                   "
   ," SIGH                                   "
   ," I'M SO BORED                           "
   ," GET LOST!                              "
   ," HE HE                                  "
   ," THANKS FOR CHEERING ME UP              "
   ," I'M NOT IN THE MOOD FOR JOKES          "
   ," YOU'RE SO FUNNY - NOT!                 "

VARIABLE MOOD
HAPPY MOOD !

: INDEX ( input entrysize rowlength -- offset )
  ROT * MOOD @ + * ;
: OUTPUT ( input -- input entrysize rowlength ) 40 4 ;
: NEWSTATE ( input -- input entrysize rowlength ) 4 4 ;

: COMMENT ( input -- input)
 CR DUP
 OUTPUT INDEX COMMENTS +
 COUNT TYPE
;
: SET-MOOD ( input -- )
 NEWSTATE INDEX NEWSTATES +
 @ MOOD !
;

: REPORT ( -- )  \ REPORTS MOOD. USAGE: REPORT
 CR ." I AM "
 CASE MOOD @
  HAPPY OF ." HAPPY" ENDOF
  SAD OF ." SAD" ENDOF
  BORED OF ." BORED" ENDOF
  ANGRY OF ." ANGRY" ENDOF
 ENDCASE
 CR
;


: ME ( input -- ) \ INTERACT. USAGE INSULT|FLATTER|BORE|AMUSE ME
 COMMENT SET-MOOD REPORT ;
Technical Details
Message-ID: <uJOdncFypb2dv4DRnZ2dnUVZ8m6dnZ2d@bt.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail
References: <m8mdnaHlF_tM5ofRnZ2dnUVZ8sKdnZ2d@bt.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10610a,c91cc243cc52869b,start
X-Google-NewGroupId: yes
X-Google-Attributes: gid1190ecade0,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 19 Jun 2010 15:01:04 -0500
From: "KezL" <growl4me@googlemail.com>
Newsgroups: a.testing.group
References: <m8mdnaHlF_tM5ofRnZ2dnUVZ8sKdnZ2d@bt.com>
In-Reply-To: <m8mdnaHlF_tM5ofRnZ2dnUVZ8sKdnZ2d@bt.com>
Subject: Re: [newbie] my first FORTH program
Date: Sat, 19 Jun 2010 21:00:50 +0100
MIME-Version: 1.0
Content-Type: text/plain;
 format=flowed;
 charset="iso-8859-1";
 reply-type=response
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Windows Mail 6.0.6002.18197
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.18197
Message-ID: <uJOdncFypb2dv4DRnZ2dnUVZ8m6dnZ2d@bt.com>
Lines: 87
X-Usenet-Provider: http://www.giganews.com
X-AuthenticatedUsername: NoAuthUser
X-Trace: sv3-fNYl7CcthgwsJzoDrpIMKbHwxuxBGf7Xbq0gv0xm5SzI22WkBAkOLJOIw2yxG3dIl79lhJT1ucmJoDM!xuHcTxUZR0D/3rrgFcNI+xa+5C0VedYG8Z1qlySfavZfQdTcfvWyh1z8X2I81CF1lSTJdrzfbw==
X-Complaints-To: abuse@btinternet.com
X-DMCA-Complaints-To: abuse@btinternet.com
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40