Jump to content
IGNORED

Forth Tutorials


matthew180

Recommended Posts

Made a classic mistake....

 

foriss1_zps5551c967.png

 

 

And then I got this........

 

foriss2_zps69cd7d2c.png

 

 

 

Disappointed, I re-read the reference card, changed to this:

 


: DRAW
XBAR 7 42 10 HCHAR

 

And then got the desired result. =)

 

 

forissfix_zps19f8dac6.png

 

 

 

***RTFM!!!!***

Edited by Opry99er
Link to comment
Share on other sites

Ahh yes, I did... The box was off center, so I changed it to 20. =)

 

Thanks for the catch there.

 

Yea, I actually thought I'd found another misleading section of the TF documentation and I started writing a post about it... Before I sent it though, I re-read the ref card and discovered it was I who was mistaken. Next I'll be re-defining some standard character sets and working toward building my title screen. (See my avatar)

 

 

Owen

Link to comment
Share on other sites

Ahh yes, I did... The box was off center, so I changed it to 20. =)

 

Thanks for the catch there.

 

Yea, I actually thought I'd found another misleading section of the TF documentation and I started writing a post about it... Before I sent it though, I re-read the ref card and discovered it was I who was mistaken. Next I'll be re-defining some standard character sets and working toward building my title screen. (See my avatar)

 

 

Owen

 

I'm pretty sure I followed the TI BASIC conventions with HCHAR/VCHAR/GCHAR with respect to the order of the arguments. I figured if I was going to use the same name as the TI BASIC versions it would be a bit of an insult to change the order of the arguments! However, unlike TIB/XB the number of repeats is not optional!

 

Forth on!

Link to comment
Share on other sites

  • 6 years later...
15 hours ago, Willsy said:

Oh my this was seven years ago! We should keep this thread alive and include fbForth and Forth99.

I can't prove it but I swear that time moves faster in the the 12st 21st century. :)

 

Nice to see you back BTW.  Hope life is treating you well.

 

I have been recounting my fun and travails over on the Camel99 Forth topic.  I will have to give some thought to some meaningful content for here.

I started a Youtube channel and the plan was to create some video to explain how to use my system and I wanted to give some demonstrations of how to do some real things in Forth.

 

Maybe that can be my contribution over here.

 

Edited by TheBF
dislexia
  • Like 1
Link to comment
Share on other sites

4 minutes ago, TheBF said:

I can't prove it but I swear that time moves faster in the the 12st century. :)

 

Type much? ? I know you meant “21st century”—and, yes, it does. I think it might have a little to do with the fact that I have far less time left on this plane than I have spent!

 

...lee

  • Like 1
  • Haha 1
Link to comment
Share on other sites

  • 2 months later...

Questions about Forth and the f4 key on console or classic99..when I make a loop, you know..loop..how do I break the loop?  Does it have to be part of the WORD or is it stuck in forever loop until I shut the computer off?     Is there a f4 break key on a loop?    A simple : TEST DO ." HELLO " LOOP ;   it goes forever...how to stop it?

Link to comment
Share on other sites

2 minutes ago, DavidC said:

Questions about Forth and the f4 key on console or classic99..when I make a loop, you know..loop..how do I break the loop?  Does it have to be part of the WORD or is it stuck in forever loop until I shut the computer off?     Is there a f4 break key on a loop?    A simple : TEST DO ." HELLO " LOOP ;   it goes forever...how to stop it?

Forth words are built on the idea that each routine should do one thing. You will find therefore that LOOP etc. have no way out. :)

 

But it is simple to add.   The word ?TERMINAL reads the F4 on the TI and returns true if it is pressed. 

So you could do this:

: ?BREAK   ?TERMINAL ABORT" BREAK KEY DETECTED!" ;

Add the word ?BREAK anywhere that you think you might want to stop the program.

 

  • Like 1
Link to comment
Share on other sites

I suppose it would be wrong to leave out just how configurable Forth is.

 

You are free to make DO/LOOP yourself in a different way if you really want to dig into how the compiler is built.

 

Or you could just add ?BREAK to the existing LOOP routine like this.

(tested with FbForth) 

COMPILE is used for ordinary (non-immediate) Forth words.

[COMPILE] is used to "compile" IMMEDIATE words.

 

Now when you use LOOP in a definition it will first COMPILE the address of ?BREAK followed by the address of LOOP ;

In other words you have changed the compiler!

 

You could do the same thing with AGAIN, UNTIL and REPEAT.  If you made a block with these words in it, you could load it first for testing programs. Then all you loops would be "breakable".

Then re-compile without the breakable loops and run at full speed.

\ breakable loop

: ?BREAK   ?TERMINAL ABORT" *BREAK*" ;

: LOOP     COMPILE ?BREAK  [COMPILE] LOOP ;  IMMEDIATE 

\ test it
: STAR     42 EMIT ;
: STARS ( n -- ) 0 DO  STAR  LOOP ;

20000 STARS ( hit fctn 4 when you get tired of it)

 

Note:For ANS Forth like CAMEL99 Forth change LOOP to:

: LOOP    POSTPONE ?BREAK  POSTPONE LOOP ;  IMMEDIATE 

 

  • Like 1
Link to comment
Share on other sites

32 minutes ago, TheBF said:

I suppose it would be wrong to leave out just how configurable Forth is.

 

You are free to make DO/LOOP yourself in a different way if you really want to dig into how the compiler is built.

 

Or you could just add ?BREAK to the existing LOOP routine like this.

(tested with FbForth) 

COMPILE is used for ordinary (non-immediate) Forth words.

[COMPILE] is used to "compile" IMMEDIATE words.

 

Now when you use LOOP in a definition it will first COMPILE the address of ?BREAK followed by the address of LOOP ;

In other words you have changed the compiler!

 

You could do the same thing with AGAIN, UNTIL and REPEAT.  If you made a block with these words in it, you could load it first for testing programs. Then all you loops would be "breakable".

Then re-compile without the breakable loops and run at full speed.


\ breakable loop

: ?BREAK   ?TERMINAL ABORT" *BREAK*" ;

: LOOP     COMPILE ?BREAK  [COMPILE] LOOP ;  IMMEDIATE 

\ test it
: STAR     42 EMIT ;
: STARS ( n -- ) 0 DO  STAR  LOOP ;

20000 STARS ( hit fctn 4 when you get tired of it)

 

Note:For ANS Forth like CAMEL99 Forth change LOOP to:


: LOOP    POSTPONE ?BREAK  POSTPONE LOOP ;  IMMEDIATE 

 

So.....all that must be in a block?    Not immediate mode?  

Link to comment
Share on other sites

10 minutes ago, DavidC said:

This is what happened using Turboforth on js99 on my chomebook....I know i am doing something wrong.  

Screenshot 2020-05-11 at 9.13.41 PM.png

Turbo Forth doesn't have the word ?terminal.  It is telling you that in error message.

 

I think you make it though.

: ?TERMINAL  KEY? 2 = ;

 

 

 

Link to comment
Share on other sites

1 minute ago, TheBF said:

Turbo Forth doesn't have the word ?terminal.  It is telling you that in error message.

 

I think you make it though.


: ?TERMINAL  KEY? 2 = ;

 

 

 

Ahhh, yes. Yes. I can make the word a word.....I keep forgetting that.  ( plus I don't know what I am doing ).  

  • Like 2
Link to comment
Share on other sites

Alright!  Now we are getting somewhere.   Awesome.  When it isnt late and I ( aint drinkin ) have time to dig deeper.. yes!  Put this in a block, with whatever my foolish code is and it will break.  It is a start, thank you! We all gotta start somewhere.  

Screenshot 2020-05-11 at 9.43.11 PM.png

  • Thanks 1
Link to comment
Share on other sites

2 minutes ago, DavidC said:

Alright!  Now we are getting somewhere.   Awesome.  When it isnt late and I ( aint drinkin ) have time to dig deeper.. yes!  Put this in a block, with whatever my foolish code is and it will break.  It is a start, thank you! We all gotta start somewhere.  

Screenshot 2020-05-11 at 9.43.11 PM.png

Forth is a lot like learning a human language. Lots of words each with a specific meaning.  BUT... you can change it as you go.

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Just now, GDMike said:

Just back up your screens, as nothing is worse than losing a formula that wasn't easy to come up with.

Paper and pen, old school.  I asked about that on stupid facebook page and yes.  Notebook full of notes.  Just in case..

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...