Home »
Public Forums »
archive »
too many local variables
Re: too many local variables [message #4796 is a reply to message #4708] |
Mon, 24 July 1995 00:00  |
knighton
Messages: 12 Registered: June 1995
|
Junior Member |
|
|
In <DC1IFL.K1v@ireq.hydro.qc.ca> brooker@toka.ireq-ccfm.hydro.qc.ca writes:
> Help!!
> I have a data analysis procedure that is up to 679 lines and when I try to add
> some new code to it I get the error
> "program unit has too many local variables"
> I then delete the new code and rerun the program. Just before the end I placed a
> STOP statement. After typing HELP I see that I have 236 local variables.
> I take it then that the limit for local variables is slighly bigger than 236?
> Has anybody else had this problem? How do you delete variables that you no
> longer need in a procedure?
There is a limit on local variable names. There are several ways to get around
this limit:
1. Use common blocks, these don't count against the local variable limit.
Be sure to keep less than 64 variables per common block however or you
will run up against another limit.
2. Partition your problem so that you use structures and arrays. A structure
or an array uses just one local variable name but can store numerous pieces
of information.
3. Break your program up into functions and procedures that are small and
accomplish simple, well-defined tasks. These modules should have only a
few variables and perhaps 25-100 lines of code each.
I have personally written applications that are thousands of lines long that
don't even come close to reaching the limit on local variables.
I think it would be helpful if all of these limits were documented somewhere.
RSI?
I hope this helps.
Ken Knighton, Systems Programmer
Work: General Atomics Home: knighton@cts.com
Magnetic Fusion Research Division
San Diego, CA
knighton@gav.gat.com
|
|
|
Current Time: Fri Oct 10 05:53:11 PDT 2025
Total time taken to generate the page: 1.12015 seconds