en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en en nl en en en en en en en en en en de en en en en en nl en en en en en en en en en en en en en nl en en en en en en en en en en en en en en nl en en en en en en en en en en en en en en en fr en da en en en en en en en nl en en en en en en en en en en en en en en fr en da en en en en en en en nl en en en en en en en en en en en en en en nl vi en en en en en en en fr en da en en en en de en en en fr en en en en en en en en en pt en en en en en en
By logging into your account, you agree to our Privacy Policy, personal data processing and storage practices as described therein.
Forgot password or user name?
Search in titles only Search in Programming only
You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
I thought this wasn't allowed....
All Time Today Last Week Last Month
All Discussions only Photos only Videos only Links only Polls only Events only
REM ************************************** ' REM * Enter a line of text on the screen * ' REM ************************************** ' REM * Written in CCv 4.04. * ' REM ************************************** ' ' DECLARE FUNCTION ScreenInput(LONG, _ ' LONG, _ ' LONG) AS STRING' ' ' FUNCTION ScreenInput(SiRow AS LONG, _ ' SiCol AS LONG, _ ' SiLen AS LONG) AS STRING ' LOCAL t AS LONG ' LOCAL x AS LONG ' etc, etc, and so on and so forth END FUNCTION
This snippet is in an #INCLUDE file (the 2nd or 3rd #INCLUDE) and was DECLARE'd before in the main file.
Thought duplicate DECLARE's was illegal but it seems it's legal in that the program compiles and runs fine (so far as it's developed).
There are no atheists in a fox hole or the morning of a math test.
If my flag offends you, I'll help you pack.
Join Date: Jan 1980
27 Mar 2008, 06:52 AM
What would make you think you can't have two DECLARE's as long as they're the same? Did you read that in the PowerBASIC doc? Could you please show us the location so we can check it out?
Join Date: Jan 2000
27 Mar 2008, 08:37 AM
What am I not seeing here? The top structure is a function declaration and the lower is its implementation?
#Compile Exe #Dim All Declare Function Foo() As Long Function Foo() As Long Foo=1 End Function Function PBMain () As Long Print "Foo() = "Foo() Waitkey$ PBMain=0 End Function
Join Date: Aug 1998
27 Mar 2008, 09:18 AM
The compiler will only flag a declare or procedure header as a 'duplication error' if it finds..
- A prior DECLARE not matching number and type of parameters and return type
- A prior procedure header not matching number and type of parameters and return type
i.e., moot duplicates are ignored.
Remember what a DECLARE really is: It is a compiler directive which says, "when you see this symbol, this is what it means".
In this case, when compiling the executable statement...
Print "Foo()=" & Foo() ' note the required '&' here!!
...if the compiler had not yet encountered the symbol "Foo" it could not know what to do. However, you had already told the compiler (via DECLARE and by Procedure Header) what "foo" means when encountered.
You don't need the DECLARE here, but only because the procedure header for 'Foo' physically precedes its use in an executable statement... but it never hurts to have a DECLARE, unless you have mismatched parameters or return data types.
Port Washington WI USA
Join Date: Aug 1998
27 Mar 2008, 10:11 AM
BTW, if you use the explicit CALL verb, the compiler does not care where the procedure header physically resides in the source module.
That may also apply to to DECLARE statements, but of that I am not certain.
Of course using the CALL form precludes the use of a FUNCTION name as a though it were a variable and you'd need two lines of code...
CALL Foo () TO S$ PRINT "Foo()=" & S$
But I suppose you could MACRO it (to make MACRO a verb)...
MACRO CallFunc (Funcname) Macrotemp S DIM S AS STRING CALL funcname to S END MACRO = S ... PRINT "Foo()=" & CallFunc (Foo)
...something like that, anyway
Port Washington WI USA
Join Date: May 1999
27 Mar 2008, 11:17 AM
I guess I got confused. Re: CC3.04 book, Page 266
PowerBasic does not support multiple declarations of an imported Sub/Function. That is, if two or more DECLARE statements use the same ALIAS name, a compile-time Error 466 ("Duplicate name definition") will occur
Don't have the 4.x book (yet). Relying on the HELP file(s) for the time being.
There are no atheists in a fox hole or the morning of a math test.
If my flag offends you, I'll help you pack.
Join Date: Aug 1998
27 Mar 2008, 12:57 PM
PowerBasic does not support multiple declarations of an imported Sub/Function. That is, if two or more DECLARE statements use the same ALIAS name, a compile-time Error 466 ("Duplicate name definition") will occur
Really? I thought that restriction was eliminated in 8.00. It was one of my complaints.
There has to be restriction on the SYMBOL name ("FOO"), but the ALIAS thing - if the above sentence may be taken literally - well that looks like either a reversion back to the past or a help-file-needs-help thing.
Port Washington WI USA
Copyright © 1998-2022 PowerBASIC Tools, LLC - All Rights Reserved.
Powered by vBulletin® Version 5.7.0
Copyright © 2022 vBulletin Solutions, Inc. All rights reserved.
All times are GMT-5. This page was generated at 11:01 PM.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.