Petit Computer Wiki
Petit Computer Wiki

Hey guys. Today is just pure bad news. I've been working with THOLITU, and I can't get its equivalent of FOR loops to work. I need help. Here's my code:

@FOR
FORLINE(ASC(MID$(LINE$(I),5,1)))=I
FOR K=13TO LEN(LINE$(I))-1
IF MID$(LINE$(I),K,1)=="*"THEN Y=VARIABLE(ASC(MID$(LINE$(I),K+1,1))):K=LEN(LINE$(I))-1
IF MID$(LINE$(I),K,1)!="*"AND MID$(LINE$(I),K,1)!=">"THEN Y=VAL(STR$(Y)+MID$(LINE$(I),K,1))
IF MID$(LINE$(I),K,1)==">"THEN K=LEN(LINE$(I))-1
NEXT
FORNUM(ASC(MID$(LINE$(I),5,1)))=Y
RETURN

And here's the equivalent to NEXT:

@FOREND
K=FORLINE(ASC(MID$(LINE$(I),3,1)))
IF MID$(LINE$(K),9,1)=="="THEN EVL=1
IF MID$(LINE$(K),9,1)==">"THEN GVL=1
IF MID$(LINE$(K),9,1)=="<"THEN LVL=1
IF EVL AND VARIABLE(ASC(MID$(LINE$(I),3,1)))==FORNUM(ASC(MID$(LINE$(K),3,1)))GOTO@NEXT
IF GVL AND VARIABLE(ASC(MID$(LINE$(I),3,1)))>FORNUM(ASC(MID$(LINE$(K),3,1)))GOTO@NEXT
IF LVL AND VARIABLE(ASC(MID$(LINE$(I),3,1)))<FORNUM(ASC(MID$(LINE$(K),3,1)))GOTO@NEXT
RETURN
@NEXT
UTS$=MID$(LINE$(K),11,1)
IF UTS$=="+"THEN VARIABLE(ASC(MID$(LINE$(I),3,1)))=VARIABLE(ASC(MID$(LINE$(I),3,1)))+1
IF UTS$=="-"THEN VARIABLE(ASC(MID$(LINE$(I),3,1)))=VARIABLE(ASC(MID$(LINE$(I),3,1)))-1
I=K
RETURN

Whew, that's a lot of code to troubleshoot. Since you guys do not have the WHOLE program, this all should be at the beginning of the PRG:

LINE$(5)=" ^*~{I}!<<:+:*N>{"
'Make sure that space is there--it is essential!
LINE$(7)=" *}I"
'Yet another necessary space!
VARIABLE(73)=5
I=5
@LOOP
IF I==5THEN GOSUB@FOR:LOOPVAR=LOOPVAR+1:GOTO@LOOP
IF I==7THEN GOSUB@FOREND:LOOPVAR=LOOPVAR+1:GOTO@LOOP
?LOOPVAR
?"If that isn't either 9, 10, or 11, something went wrong"
END