Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!willett!ForthNet From: ForthNet@willett.UUCP (ForthNet articles from GEnie) Newsgroups: comp.lang.forth Subject: ANS TC Magnet for LOOPS, EXIT, Term. Message-ID: <578.UUL1.3#5129@willett.UUCP> Date: 27 Feb 90 23:55:36 GMT Organization: Latest link in the ForthNet chain. (Pgh, PA) Lines: 38 Date: 02-26-90 (08:19) Number: 2974 (Echo) To: STEVE PALINCSAR Refer#: 2965 From: IAN GREEN Read: NO Subj: DO LOOPS IN FORTH Status: PUBLIC MESSAGE The reason for using FOR-NEXT is that I saw a comment comparing FOR vs. DO in the RTX2001 data sheet. It said FOR runs several times faster so I assumed that this was a standard word in Forth. >Ian, you're probably looking for something like this: >: LOOP_DEMONSTRATION ( n2 n1 -- ) >\ That is, both the inner and outer loop limits are on the stack >\ before this word executes. You could put them there by fetching >\ from a couple of variables, or whatever other means you like. > 1 DO ( Takes n1 from param stack, puts in on Rstack ) > 1 DO ( Takes n2 from param stack, puts it on Rstack ) ( whatever you want to execute ) > LOOP > LOOP ; > In the help conference I saw a note that described a different syntax. It used the FOR-NEXT syntax and demonstrated the control variable (I need to be able to use the control variable inside the loop) and it like your code used a 1. My question, what does the 1 do? The code was something like : FORSAMPLE 1 M FOR wordsequence NEXT ; Eventually I will get this together. Thanks Ian Green NET/Mail : British Columbia Forth Board - Burnaby BC - (604)434-5886 ----- This message came from GEnie via willett through a semi-automated process. Report problems to: 'uunet!willett!dwp' or 'willett!dwp@gateway.sei.cmu.edu'