Thanks for the assistance.
------------------
Michael Burgett
Announcement
Collapse
No announcement yet.
Proper use of $Stack $String
Collapse
X
-
I still use PDS for my DOS projects because of all the tools I have for it. I've been
looking for a reason to switch to PBDos, but probably won't for
a while unless some specific reason comes up.
I just went through a DOS programming project where I ran into
the stack overflow problem a lot. I worked around it by choosing
strategic points in the program where it would just restart,
using CHAIN, therefore clearing the stack. So far that method has
worked quite well for me. It's transparent to the user.
------------------
[This message has been edited by Shawn Anderson (edited July 11, 2003).]
Leave a comment:
-
One day you'll wish you had more [memory]
Heard that somewhere, but I think it was at least a couple of months ago...
MCM
Leave a comment:
-
If you set the stack too high you lose workable memory. I know this
sounds trivial, but trust me! One day you'll wish you had more.
Besides, in the way things work in DOS, a program's not done 'til
theres no room to run ... in memory, chuckle!
------------------
Mike Luther
[email protected]
Leave a comment:
-
what is the trade off for setting the stack too high?
------------------
Leave a comment:
-
Here's how I've worked at this for years .. in principal.
Take your most frequent major menu screen, or what passes for it, one
that you will return to over and over again in your program, if that
is possible.
Next look at the PB Reference Manual for the FRE function, say the FRE(-2)
variation that has to do with the Stack space which has never been used.
Take the most applicable line in your major menu screen, or what passes
for it, and simply add a semi-colon to the end of the print statement
for a line, adding a FRE(-2) function to it. That way each time you
cycle through the line you'll get a report on the remaining Stack space
left at that point. You can also use the FRE(-4) function to determine
string space and so on.
You use this as a temporary help technique during your research work on how
the program runs. When you are satisfied you have provided enough for your
particular purposes, simply comment out the test part and leave the test
code there for later if needed.
Another way to use things like this is to actually use a variable which you
can set that designates the program is running in a TEST mode. If that
variable is set to the needed value at the start of the program, then
portions of the program used for testing 'come alive' you, the developer,
can see. On release, you clear the variable.
In extreme cases where it becomes necessary to be able to switch the program to
a TEST mode in a distributed environment, you can carry in a needed variable to
set that TEST mode to on either via a variable value you read from a normally
opened data file that feeds your program. Or, as an alternative, you can also
use the function in PB that carries in a COMMAND LINE parameter. Passage of the
required COMMAND LINE parameter into you program, as needed, for TEST purposes,
gains you access to parts of the program that may tell you what a user is doing
which you won't normally see. We all get into the position as coders, that we
think this or that way is the way a program is used, when, others can seemingly
figure out the darnedest ways to defeat what we think is right!
------------------
Mike Luther
[email protected]
Leave a comment:
-
STACK actually CAN be calculated.. but only if you have a limited Real Life.
$STRING, on the other hand, has discrete allowed values; the value you set is totally application-dependent.
Bottom line on $STRING is, "how much memory will be allocated for the first character when you need string space, and the maximum individual string length permitted."
If you have nothing but tiny strings, you can get away with a smaller $STRING segment size, which saves on overall system memory usage.
MCM
Leave a comment:
-
As far as I know, there are no procedures for calculating a
value for these statements.
If you have a rather smallish program, you should be able to
get away with the default value of $STACK. On the other hand,
if you have a lot of subs-n-functions, you will have to
increase the value to keep the stack happy. Just play with the
value until your program runs.
In as far as $STRING goes, you will have to mentally figure the
worst case and go from there.
Sorry if this answer is a little vague, but.....
------------------
Leave a comment:
-
Proper use of $Stack $String
I would like to know how I would determine the correct values for
these metastatements. What is the procedure for calculating these
values. I apprieciate any help in explaining this to me.
Thank you.
------------------
Michael BurgettTags: None
Leave a comment: