Author Topic: LabelLine Edit  (Read 7021 times)

0 Members and 1 Guest are viewing this topic.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
LabelLine Edit
« on: November 27, 2012, 11:14:59 pm »
I got this idea from Deep Thought, I modified it slightly, but I need some input:
This might be hard, but how about writing back a string to a label in the program? Something like

Code: (TI-BASIC) [Select]
:Lbl 0
:{1,1,2,3
:Lbl 1
:Ans→L₁
:"{1,3,4,7→Str1
:"0,1
:Asm(SMC

True SMC in BASIC is something we have yet to see :D
I modified the syntax to be more easily used by BASIC programmers (I hope), so here is what I have:

prgmLBLLINER is "Label Line Read" and will let you read a line at the offset of a label. Str1 contains the name of the label, followed by a colon (sorry). Ans contains the line number to read. If Ans is zero, this program will instead return how many lines there are until the end of the program. So for example:
Code: [Select]
"MD:→Str1
3
Asm(prgmLBLLINER
Pause Ans
Return
Lbl MD
Bulbasaur
Ivysaur
Venusaur
...
This code will return "Venusaur" in Ans.
prgmLBLLINEW is "Label Line Write" and will let you replace a line after a label. The syntax is the same as before, except the data to replace with follows the colon. If there is nothing after the colon, the line is made empty. For example:
Code: [Select]
"MD:!PEANUTS→Str1
3
Asm(prgmLBLLINEW
Return
Lbl MD
Bulbasaur
Ivysaur
Venusaur
...
That code will change the line reading "Venusaur" to "!PEANUTS" Also, setting Ans to zero as the input will return the number of lines left in the program after the label.

So here is my question... Alone, these programs are 204 and 285 bytes respectively. However, they share almost all the same code, so combined it would be a little over 300 bytes. I was thinking that having a decimal part in Ans (like 3.1) could tell the program to read a line, and no decimal part would tell it to overwrite a line. Does this sound like a good syntax?

EDIT: Also, that quote came from my hex opcodes topic. If you want the hex opcodes for these, be prepared to input a long code XD
EDIT2: See below for an updated version!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: LabelLine Edit
« Reply #1 on: November 28, 2012, 01:09:30 pm »
Yay, an update. Boba Foxx from TIBD gave the idea of using a factorial token "!" as a prefix in Str1 to tell the program to read a line. The program is now 334 bytes and is able to read/write to lines of code in the program. Now it is super useful >:D