DECLARE FUNCTION curiosity

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

DECLARE FUNCTION curiosity

Postby Flyzone » Apr 22, 2021 2:43

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: 528
Joined: Sep 27, 2016 18:20
Location: Valencia, Spain

Re: DECLARE FUNCTION curiosity

Postby Josep Roca » Apr 22, 2021 2:49

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

Re: DECLARE FUNCTION curiosity

Postby Flyzone » Apr 22, 2021 2:52

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

Re: DECLARE FUNCTION curiosity

Postby Flyzone » Apr 22, 2021 2:57

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.

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 9 guests