Foros: Forum of Decimal BASIC (Thread #690845)

Reference an internal function from an external function? (2024-02-08 09:27 by toml12953 #737459)

Is it possible to call an internal function from an external sub or function?

I tried using DECLARE in the external function but it doesn't work.

The error happens in external sub trymove when I try to execute internal function validmove

DECLARE FUNCTION validmove
DECLARE EXTERNAL SUB trymove
<main program goes here>

FUNCTION validmove(X, Y)
LET validmove = FALSE
IF X<0 OR X>7 OR Y<0 OR Y>7 THEN EXIT FUNCTION
IF Board(X,Y)=FALSE THEN LET validmove = TRUE
END FUNCTION

END

EXTERNAL SUB trymove(X, Y, M, newx, newy)
DECLARE FUNCTION validmove
IF validmove(X, Y) = 0 THEN EXIT SUB
IF validmove(X+1,Y+2) <> 0 THEN LET N = N + 1
IF N>M THEN EXIT SUB
IF N=M AND RND<.5 THEN EXIT SUB
LET M = N
LET newx = X
LET newy = Y
END SUB

Responder al #737459×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Entrar