To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.pbforthOpen lugnet.robotics.rcx.pbforth in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / pbFORTH / 378
377  |  379
Subject: 
RE: Forth question
Newsgroups: 
lugnet.robotics.rcx.pbforth
Date: 
Wed, 24 May 2000 03:14:00 GMT
Viewed: 
1493 times
  
I'm trying to define a constant in a compiled word.

: zzz 1 CONSTANT ONE ;

I know its not right. It tries to compile "ONE" which is not
what is wanted. What is the right way to say this?

1 CONSTANT ONE

Recall that CONSTANT is a *defining* word, just like the ":"

It makes a name in the dictionary, in this case "ONE" and then
links to a special bit of code that is executed every time
ONE is interpreted. It grabs the value out of the cell, in this
case 1, and puts it on the stack.

Cheers,

Ralph Hempel - P.Eng

--------------------------------------------------------
Check out pbFORTH for LEGO Mindstorms at:
<http://www.hempeldesigngroup.com/lego/pbFORTH>
--------------------------------------------------------
Reply to:      rhempel at bmts dot com
--------------------------------------------------------



Message has 1 Reply:
  Re: Forth question
 
(...) I still want to create a constant from within a definition. I have an initializing word that will calculate the value of the constant. For various reasons I can't do this calculation except within the runtime behavior of the word. This is not (...) (25 years ago, 24-May-00, to lugnet.robotics.rcx.pbforth)

Message is in Reply To:
  Forth question
 
I'm trying to define a constant in a compiled word. : zzz 1 CONSTANT ONE ; I know its not right. It tries to compile "ONE" which is not what is wanted. What is the right way to say this? (25 years ago, 24-May-00, to lugnet.robotics.rcx.pbforth)

9 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR