[Coco] Back to DEF FN

Arthur Flexser flexser at fiu.edu
Mon Jan 27 23:20:39 EST 2014


Rogelio,

That's because you defined a function that only involves what to the
function is considered constants, that is, non-arguments.

If you'd defined the function as FNRE(A)=X-INT(X/Y)*Y+A, and then set some
variable Q equal to 3 and printed FNRE(Q), you'd get the value of X mod Y
with 3 added to it.

Art


On Mon, Jan 27, 2014 at 11:07 PM, Rogelio Perea <os9dude at gmail.com> wrote:

> On Mon, Jan 27 2014, William Astle wrote:
>
> Actually, it's not working. Try using something other than N1 and N2 in
> > your input and print statements. Say use X and Y.
> >
>
> Your note prompted a little bit more testing on this end. Rewrote the MOD
> routine as:
>
> 10 DEF FNRE(A)=X-INT(X/Y)*Y
> 20 CLS
> 30 INPUT"NUMBER 1";X
> 40 INPUT"NUMBER 2";Y
> 50 PRINT
> 60 PRINT X;"MOD";Y;"IS;"FNRE(Z)
> 70 PRINT
> 80 GOTO 30
>
> and it works. So only a dummy variable is needed to define the function, it
> can be defined with one and called using another. To this day I held the
> idea that on the function side one had to stick to the variables
> established in the DEF FN side... so I did learn something new today.
>
>



More information about the Coco mailing list