Classic Computer Magazine Archive COMPUTE! ISSUE 43 / DECEMBER 1983 / PAGE 10


The statement DEF FN does not work in Atari BASIC. How can I convert DEF and FN statements to work on my Atari?

Sam Scarfina

First you need to define what an "alien" BASIC'S commands do in order to translate them. The purpose of DEF is to define a user-written function. Functions intrinsic to Atari BASIC include COS, INT, SQR, FRE, etc. DEF FN would let you create your own function. For example, DEF FND2(V) = V/2 is a function that divides a number by two. PRINT FND2(10) then would give you a five, and FND2(3) gives 1.5. The variable V, called a dummy variable, defines the relationship of the number you give the function. You can still use V in your program (and you don't have to use V as the dummy argument) as its value won't be changed by a FN statement.

On the Atari, you can just write a subroutine to accomplish the same thing. For example:

1000 X = X/2 : RETURN

Just set X equal to the value in the function's parentheses, GOSUB 1000, and assign X appropriately. You can even name the subroutine with DIV2 = 1000 and then GOSUB DIV2.