DECLARE FUNCTION curiosity

New to FreeBASIC? Post your questions here.
Post Reply
Flyzone
Posts: 109
Joined: Nov 17, 2017 17:39

DECLARE FUNCTION curiosity

Post by Flyzone »

If I declare a function (before use of the function) as:

Code: Select all

DECLARE FUNCTION GenSortKey (SortRec AS STRING,_
    SortKeyStartLoc() AS INTEGER,_ 
    SortKeyLeng() AS INTEGER,_ 
    SortKeySeq() AS STRING)_
        AS STRING
... I have no compile or execution problems.

However, if I declare the function moving the first parameter to a continuation line it then does not compile, such as:

Code: Select all

DECLARE FUNCTION GenSortKey_
    (SortRec AS STRING,_
    SortKeyStartLoc() AS INTEGER,_ 
    SortKeyLeng() AS INTEGER,_ 
    SortKeySeq() AS STRING)_
        AS STRING
This gives me the error ...
"Variable not declared, SortRec"

As a parameter, SortRec is not DIMensioned in either case.

Should that happen?
Josep Roca
Posts: 564
Joined: Sep 27, 2016 18:20
Location: Valencia, Spain

Re: DECLARE FUNCTION curiosity

Post by Josep Roca »

Use GenSortKey _ instead of GenSortKey_. Otherwise, the _ will be part of the function name, not a line continuation.
Flyzone
Posts: 109
Joined: Nov 17, 2017 17:39

Re: DECLARE FUNCTION curiosity

Post by Flyzone »

That does it. Thanks.
Flyzone
Posts: 109
Joined: Nov 17, 2017 17:39

Re: DECLARE FUNCTION curiosity

Post by Flyzone »

That does it. Thanks.

Kinda weird that the underscore is the ONLY special character that can be used in var names but is also used for continuation.
Post Reply