Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
FOCAL (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====FOR==== The {{code|FOR}} command (abbreviation F) implements a [[for loop]]. When three arguments are specified, the first is the initial value of the loop variable, the second is the increment, and the third value is the terminating value for the loop. If only two values are provided, the first is the initial value and the second is the terminating value, and the increment is set to 1. This is the pattern from [[FORTRAN]]'s {{code|DO}} loops, as opposed to BASIC's {{code|FOR}} where the increment is the last value, if present. In contrast to other parts of the language where multiple statements on a line are independent, the {{code|FOR}} always runs the statements that follow it on the line before the termination has been met, and then continues to the next line. Thus, loops have to be on a single line, or alternatively, call a subroutine with {{code|DO}}. There is no equivalent of BASIC's {{code|NEXT}}.{{sfn|Manual|1968|p=3.7}} 01.01 FOR X=1,10; TYPE X,! 01.02 FOR X=0,10,100; DO 2 A sample FOR loop: 01.10 ASK "HOW MUCH MONEY DO YOU WANT TO BORROW ?",PRINCIPAL 01.20 ASK "FOR HOW MANY YEARS ?",TERM 01.30 FOR RATE=4.0,.5,10;DO 2.0 01.40 QUIT 02.10 SET INTEREST=PRINCIPAL*(RATE/100)*TERM 02.20 TYPE "RATE",RATE," ","INTEREST",INTEREST,!
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)