Applesoft: CHAIN and user-defined functions Issues

User defined functions in Applesoft may cause problems when the CHAIN command is used.
This article has been archived and is no longer updated by Apple.
When Applesoft encounters a DEF FN statement, an entry is made in the simple variable table which points to the rest of the function in the text of the program. Strange and perhaps fatal things can happen if you use this functon defined in the previous program without having the same image of the function at the same memory locations.

The easy way around this problem is avoid using defined functions, or re-define all of your defined functions in each of the chained modules.

First program:
5 REM PROGRAM 1
10 DEF FN A(X)=X*X
20 PRINT FN A(2)
30 PRINT CHR$(4);"BLOAD CHAIN,A520"
40 CALL 520"PROGRAM 2"

Second program:
5 REM PROGRAM 2
10 DEF FN A(X)=X*X
20 PRINT FN A(2)
30 END
Published Date: Feb 20, 2012