1

Is it possible to Execute TI BASIC from a string? Such that: execute(":Disp Str1") would Print out Str1?

Scraps
  • 13
  • 2

2 Answers2

2

It could be done with a small Asm( program that takes a string (from Ans), turns it into a BASIC program, and executes it. For example:

.nolist
#include "ti83plus.inc"
.list
    .org userMem-2
    .db $BB,$6D
    ld hl,SavesScreen
    ld (hl),tTheta
    inc hl
    ld (hl),0
    inc hl
    push hl
    bcall(_AnsName)
    rst rFindSym
    ex de,hl
    ld c,(hl)
    inc hl
    ld b,(hl)
    dec hl
    inc bc
    inc bc
    pop de
    ldir
    ld hl,SavesScreen
    ld a,6
    bcall(_ExecuteNewPrgm)
    ; no ret because _ExecuteNewPrgm does not return

This is not ideal,

  • No safety in case Ans did not contain a string (could be added).
  • A program named θ should not exist, because it will be overwritten. If prgmθ already exists and is archived, then it does not work at all. (could be improved)
  • prgmθ is not deleted afterwards. (not sure how to do this)
  • When prgmθ is done, it quits to the Homescreen, it does not return to the calling program. (not sure how to do this)

Aside from that, it does work, for example:

:"TESTING->Str1
:":Disp Str1
:Asm(prgmRUNSTR

Looks like this afterwards:

screen

You can create the assembly program by typing this into a normal program:

AsmPrgmBB6D21
EC86365B2336
0023E5EF524B
D7EB4E23462B
0303D1EDB021
EC863E06EF3C
4C

It can be made smaller with AsmComp(.

harold
  • 61,398
  • 6
  • 86
  • 164
0

Unfortunately, no, not like this- expr and eval only work on expressions.

iPhoenix
  • 719
  • 7
  • 20