Here's a revised version of the python interpreter.

Code:

# predefining things
rcs = " ABCDEFGHIJKLMNOPQRSTUVWXYZ.,?:"
cursor = 0
memory = 0
accumulator = 0
flag = False
# starting up
print("RADISH interpreter V1.1")
p = input("Program:")
labels = {}
for i, ch in enumerate(p):
    if ch.isdigit() and ch != "0":
        labels[int(ch)] = i
while cursor < len(p):  # checks if cursor position is further than the program
    sub = p[cursor]  # stores part of program to be evaluated
    if sub.isdigit() and sub != "0":
        cursor += 1
        continue
    if sub == "z":
        if not flag:
            cursor = labels.get(accumulator, cursor)
            continue
    if sub == "n":
        if flag:
            cursor = labels.get(accumulator, cursor)
            continue
    if sub == "j":
        cursor = labels.get(accumulator, cursor)
        continue
    if sub == "r":
        memory = 0
    if sub == "a":
        accumulator += 1
    if sub == "d":
        memory -= 1
    if sub == "i":
        memory += 1
    if sub == "s":
        memory *= accumulator
        accumulator = 0
    if sub == "c":
        accumulator = memory
    if sub == "f":
        if flag >= memory:
            memory += 1
    if sub == "/":
        previous = memory  # temporary variable
        memory = accumulator
        accumulator = previous
        del previous
    if sub == "<":
        if accumulator <= memory:
            flag = True
        else:
            flag = False
    if sub == ">":
        if accumulator >= memory:
            flag = True
        else:
            flag = False
    if sub == "0":
        accumulator = 0
    if sub == "h":
        print(rcs[memory % len(rcs)], end="")
    cursor += 1

I'm probably going to publish this to codeberg, so I can regularly update it, and because it is not blocked by my school.
I have rewritten the interpreter in JavaScript, and I am now hosting it through neocities on https://claculator.neocities.org/
How much did it cost for the domain?
It's hosted through neocities, so it was free.
I made RADISH in C for the CE, but after you enter a program and hit enter, it just exists, not showing anything about the execution. Here's the code

Code:

#include <stdbool.h>
#include <tice.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "input.h"

void printText(const char *text, uint8_t x, uint8_t y);

int main(void)
{
    os_ClrHome();
    os_HomeUp();
    char program[1000];
    char rcs[] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ.,?:";
    char sub;
    int cursor = 0;
    int memory = 0;
    int accumulator = 0;
    int labels[10] = {};
    int previous;
    bool flag = false;

    printText("RADISH interpreter V1.1", 0, 0);
    while (!(os_GetCSC())) {}
    os_ClrHome();
    os_HomeUp();
    input(program,"");
    while (os_GetCSC());
    for (int i = 0; program[i] != '\0'; i++) {
        char ch = program[i];
        if (isdigit(ch) && ch != '0') {
            labels[ch - '0'] = i;
        }
    }
    while (cursor < strlen(program)) {
        sub = program[cursor];
        if (isdigit(sub) && sub != '0') {
            cursor++;
            continue;
        }
        if (sub == 'z') {
            if (!flag) {
                if (accumulator >= 1 && accumulator <= 9 && labels[accumulator] != 0) {
                    cursor = labels[accumulator];
                }
                continue;
            }
        }

        if (sub == 'n') {
            if (flag) {
                if (accumulator >= 1 && accumulator <= 9 && labels[accumulator] != 0) {
                    cursor = labels[accumulator];
                }
                continue;
            }
        }

        if (sub == 'j') {
            if (accumulator >= 1 && accumulator <= 9 && labels[accumulator] != 0) {
                cursor = labels[accumulator];
            }
            continue;
        }
        if (sub == 'r') memory = 0;
        if (sub == 'a') accumulator++;
        if (sub == 'd') memory--;
        if (sub == 'i') memory++;
        if (sub == 's') {
            memory *= accumulator;
            accumulator = 0;
        }
        if (sub == 'c') accumulator = memory;
        if (sub == 'f') { if (flag >= memory) memory += 1; }
        if (sub == '/') {
            previous = memory;
            memory = accumulator;
            accumulator = previous;
        }
        if (sub == '<') {
            if (accumulator <= memory) flag = true;
            else { flag = false; }
        }
        if (sub == '0') accumulator = 0;
        if (sub == 'h') printf("%c", rcs[memory % (sizeof(rcs) / sizeof(rcs[0]))]);
        cursor++;
    }
    while(!os_GetCSC());
    return 0;
}
void printText(const char *text, uint8_t xpos, uint8_t ypos)
{
    os_SetCursorPos(ypos, xpos);
    os_PutStrFull(text);
}

You can also access it here: https://tiplanet.org/pb/?id=383583_1772025317_b4ce0c71b0&file=main.c
Unless I'm missing something, it's because your input routine only accepts uppercase characters, and in your execution loop you're looking for lowercase characters--there clearly will be none, so that loop just spins and doesn't print anything.

Generally, what I've done in the past is adapt the example function for text input using os_GetCSC (which it looks like you've already found) to take another argument for the input mode, kind of like TI-OS does. You can have separate arrays for uppercase, lowercase, and numbers/special characters, and set things up to toggle between them with the alpha key.
Big update! I have successfully wrote a CE C interpreter for RADISH V2.0, the new version of RADISH.
New features:
Replaced < and > commands.
Memory is now an array (similar to brainfuck). Memory starts at 0 and has 1000 separate 8 bit integers, but the accumulator is still its own thing right now (will proabablyremove eventually)
Added M and W commands for the added memory feature, M moves the memory pointer down, and W moves the memory pointer up.

Here's the TIplanet project: https://tiplanet.org/pb/?id=383583_1772025317_b4ce0c71b0
Feel free to drop any suggestions, I will submit to the archives soon!
RADISH V2 CE has been submitted to the archives, and is awaiting certification!
Update: RADISH V2 CE has been accepted, but there are some bugs to patch (I'll update this post when bugfixes happen)
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 3 of 3
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement