Hi again everyone!
The other day I posted a question about function declarations, etc. In
gearing around this afternoon, I came upon the solution to my question,
and thought I'd pass it along, in case anyone was about to jump in with
more questions or a response.
It had to do with how to declare functions that are part of the same
source file you're compiling, if you've turned on full array/variable
declarations.
The declarations I'd used (which were OK) for the functions I had
difficulty with are as follows:
DECLARE FUNCTION Trim$(BYVAL STRING) AS STRING
DECLARE FUNCTION GetNCWord(BYVAL STRING, BYVAL STRING) AS STRING
and then in the function definitions ...
FUNCTION Trim$(BYVAL StringContents AS STRING) LOCAL
FUNCTION GetNCWord(BYVAL NCBlock AS STRING, BYVAL Letter AS STRING) LOCAL
As you can see, I had omitted the returned type of the function
in the function definitions, and they should have read as follows:
FUNCTION Trim$(BYVAL StringContents AS STRING) LOCAL AS STRING
FUNCTION GetNCWord(BYVAL NCBlock AS STRING, BYVAL Letter AS STRING) LOCAL AS
STRING
This raises a couple of other questions though. Other than the obvious
Trim$ name and the AS STRING type declaration of one of the functions,
what redundancies exist in what I've done?
What precisely does the LOCAL keyword do in a function definition?
How many of you actually leave the full array/variable declaration
requirement on _ALL_ the time? Under what conditions might you turn it
off? It seems to be a bit of a pain to keep all that stuff in line for
what many of you will consider to be a trivial program.
And on a slightly different PowerBASIC topic ...
What does PowerBASIC do with constants when they're declared? I know
that it's possible, though undesirable, to have two *variables* of two
different types called (for example) Nuts$ and Nuts#. This seems to be
impossible if you've turned on the full variable checking, because you
can't declare them this way. Please correct me if I'm wrong.
Now, as I understand it, PowerBASIC declares named constants by
preceding the "variable name" with the type, something called an
"equate." If I declared a constant called %TRUE, which I obviously might
use as the integer representation of a boolean flag, must I also
use %TRUE throughout the body of the program when evaluating some
expression relationship to %TRUE, or can just TRUE be made to suffice?
Thanks for taking the time to look through this with me.
-= Steve Legg -=- RelayNet ->CRS =-
-= Oshawa, Ontario CANADA -=- steve.legg@canrem.com =-
---
* OLXWin 1.00a * IF STONE(ROTATION) > 1 THEN MOSS(PROPAGATION) = 0
--- QScan/PCB v1.17b / 01-0348
---------------
* Origin: FidoNet: CRS Online, Toronto, Ontario (1:229/15)
|