Was self-modifying-code possible using BASIC?
Parameters:
- On commonly affordable home-computers before 1984
- Code that changes its own instructions while it is executing
- Using BASIC only
- Not using peek, poke or assembly language
Possible types of solutions:
Were there any machines on which the following theoretical example program might work?
10 Let Line 20 = Print "word"
20 Print "nothing"
Or just:
10 Let Line 10 = Print "word"
Or the following pseudo-code?
10 Print "10 Print "word"" + [ A special carriage-return that makes the computer accept this as the new 'Line 10' ]
In the example above, if you print the new line 10 to the screen, is there any special carriage-return that makes the computer accept this as the new 'Line 10'?
Note:
- If you did get the computer to modify a line, and you modified the line to be longer than it originally was, could it unknowingly overwrite part of the following line? Outside of program execution mode if you modify a line to be longer than it was, the computer knows how to shift data forward.
I would probably have to ask a separate question to ask:
- How was self-modifying-code used to save space?
- Were there any other interesting uses for self-modifying code that would have been possible on the machines specified in this question?
- Could you somehow set a data file as the new current program?
- How many programs or data files could be held at one time?
____________________________________________
EDIT -
Anyone heard of 'something like' EDITLN or EDITLINE or LINEDIT statement in BASIC for editing lines of a program's own code while executing ?
I seem to remember a statement that was spelled 'something like' EDITLN or EDITLINE or LINEDIT, and wonder if maybe there was one -
- In any version of BASIC
- Used for editing lines of a program's own code while executing
____________________________________________