I did some programming on the TRS-80 Model 4 back in the 80's so it has been a 
long time.

I did add some functionality using machine code. I had a screen that displayed 
options to the user but took a long time to print it. So the first time it 
printed it dump the screen to memory. The every other time it was needed it 
move the info from the data to the screen.

For a function, I used a subroutine. For example:
100 X=20 'argument of function
110 GOSUB 1000 'calculate y=myfunction(x)
120 R=A+B*Y
130 continue program


1000 REM this is the myfunction, input x, returns y
1010 function statements
1020
1030
1040
1050

1080 Y= .... REM Result of function
1090 RETURN

Don't know if that if what you were looking for. Obviously not as clean as 
R=A*MYFUNCTION(X)


----- Original Message -----
From: "Bill Gunshannon via cctalk" <cctalk@classiccmp.org>
To: cctalk@classiccmp.org
Cc: "Bill Gunshannon" <bill.gunshan...@hotmail.com>
Sent: Tuesday, April 1, 2025 9:05:56 PM
Subject: [cctalk] Why I am not worried about AI taking over the world!

So, I am working on another fun project on my trusty old TRS-80's.
I need the ability to do multi-line functions which TRS-80 BASIC
does not support.  But in hopes of finding something where someone
added that capability in the distant past (there were lots of features
added by various people over time) I decided to just try a Google
Search.  As we all know Google now begins results with an AI generated
answer to your question.  This is what I got:
--------------------------------------------------------------------------
In TRS-80 BASIC, you can create multi-line functions (subroutines)
  using the DEF FN statement, allowing you to define a function that
  can perform a specific task and be called from different parts of
  your program.

Here's how it works:

DEF FN Statement:

You use the DEF FN statement to define a function, followed by the
function name (e.g., FNMyFunction), a set of parentheses for any
arguments, and then the code that the function will execute.

Example: 10 DEF FNC(X,Y) = X*X + Y*Y defines a function named FNC
  that takes two arguments (X and Y) and returns the sum of their squares.
Function Call:
To use the function, you simply call it by its name, passing in the
  necessary arguments.
Example: 20 PRINT FNC(3,4) would print the value returned by the FNC
  function when called with arguments 3 and 4, which is 25.
Multi-line Functions:
You can extend the DEF FN statement to span multiple lines, allowing
  for more complex logic within the function.
Example:
Code

         10 DEF FNC(X,Y)
         20  LET TEMP = X * X
         30  LET TEMP = TEMP + Y * Y
         40  DEF FN END
         50 PRINT FNC(3,4)
This example defines a function that calculates the sum of squares
  of two numbers, but the calculation is broken down into multiple
  lines for readability.
Key Points:
Line Numbers:
TRS-80 BASIC relies on line numbers, so make sure to use them
  appropriately when defining multi-line functions.
Function Name:
Function names must start with FN followed by a valid identifier
  (e.g., FNC, FNMyFunction).
DEF FN END:
You need to use DEF FN END to mark the end of the function
  definition, especially when using multi-line functions.
Scope:
Functions are defined within the scope of the program and are
  accessible from anywhere in the program.
  -----------------------------------------------------------------------

Which is both wrong and totally absurd.

And I see things all the time about letting AI write your code for you.
Does anyone actually trust AI to write code?

bill

Reply via email to