arraysvisual-studio-codebasic8-bitcommodore

# DEF FN(x) How does one transfer / translate "Define Function" command to VB.NET?

The 8bit code is:

``````...
90 DEF FNX(D)=INT(RND(0)*D*8-D*3)
100 DEF FNDS(D)=INT(SQR(ABS(P(D,0)-P(L,0))^2+ABS(P(D,1)-P(L,1)^2+ABS(P(D,2)-P(L,2))^2))
...
150 FOR I = 1 TO 9 :...
...
180 P(I,0)=FNX(I):P(I,1)=FNX(I):P(I,2)=FNX(I)
...
220 NEXT I
...
1080 FOR I=0TO9 : P(I,6)=FNDS(I) :NEXT :...
...
``````

So, my main question is:- The old 8bit Define Function `DEF FN(x)` command converts to what in vb.net?

I'm trying to convert an old game from a games book my dad bought me for Christmas when I was 8. for this Christmas some thirty years on.
Commodore16 Games Book, Star Trader, Melbourne House, pp201-215, isbn:0-86161-185-3

about. (New to modern ways) Why are certain commands removed? For example: in later versions of BASIC or its equivalent VB.NET, `DEF FN(X)` is no longer, and the alternative is left unanswered / unclear.

Thanks, list what you would appreciate in return for help. No promises, if it is unrealistic, I will take it as humour.

Solution

• Untested, but something along the lines:

For `90 DEF FNX(D)=INT(RND(0)*D*8-D*3)`

``````Function MyX(ByVal D As Double) As Integer
Return CInt(Rnd(0)*D*8-D*3)
End Function
``````

For `100 DEF FNDS(D)=INT(SQR(ABS(P(D,0)-P(L,0))^2+ABS(P(D,1)-P(L,1)^2+ABS(P(D,2)-P(L,2))^2))`

``````Function MyDS(ByVal D As Double) As Integer
Return CInt(Sqrt(Abs(P(D,0)-P(L,0))^2+Abs(P(D,1)-P(L,1)^2+Abs(P(D,2)-P(L,2))^2))
End Function
``````

For `180 P(I,0)=FNX(I) : P(I,1)=FNX(I) : P(I,2)=FNX(I)`

``````P(I,0) = MyX(I) : P(I,1) = MyX(I) : P(I,2) = MyX(I)
``````

For `1080 FOR I=0 TO 9 : P(I,6)=FNDS(I) : NEXT`

``````For I = 0 To 9
P(I,6) = MyDS(I)
Next
``````