This is my current TGUI routine (Text GUI). I tried to make it as small and fast as possible, but are there any more optimizations I could do?

That weird small 'E' == the 2nd-Comma 'E' (whatever the heck it's called).

Syntax:
Menu (finally made it display more than eight items now - yay!)
"0MENU ITEM 1EMENU ITEM 2EITEM 3EITEM 4 (and so-on)
Returns selected item in Ans and X.

Numerical Input
<lower bound> -> U
<upper bound> -> V
"1<default number>
Returns selected number in Ans and X.

Text Evaluation Wrapper
"2
Return entered text (or evaluation) in Str7.

BASIC Code wrote:
:Ans→Str7
:expr(sub(Ans,1,1→W
:sub(Str7,2,length(Str7)-1→Str7
:W
:If Ans=1
:Goto 1
:If Ans=2
:Goto 2
:Str7+"E→Str7
:0→nMin
:DelVar W{0→A
:Repeat max(PMT={21,22
:1→θMin:1→X
:If nMin≥length(Str7
:DelVar W0→nMin
:If not(max(nMin=∟A
:nMin→∟A(1+dim(∟A
:ClrHome
:Repeat θMin>8 or nMin≥length(Str7
:nMin+1→PMT
:inString(Str7,"E",Ans→nMin
:Output(θMin,2,sub(Str7,PMT,Ans-PMT
:1+θMin→θMin
:End
:Ans-1→θMin
:Repeat X<1 or X>θMin or max(PMT={21,22,105
:Output(X,1,">
:1→C/Y
:Repeat Ans
:prgmXTEMP010
:getKey→PMT
:End
:Output(X,1," 
:expr(sub("ππ788ππ456ππ123ππππππ",1+(PMT>65)(PMT-75-(5(int((PMT-80)/10)))),1
:If Ans≠π and Ans≤θMin
:Then:Ans→X
:Else
:X+(PMT=34)-(PMT=25→X
:End
:End
:If X≥1:Then
:W+1→W
:Else
:If W:Then
:∟A(W→nMin
:DelVar XW-1→W
:Else
:∟A(1+W→nMin
:End
:End
:End
:DelVar Str7Ans-1+8(W-1→X
:If PMT=22:‾1→X
:ClrHome
:Return
:Lbl 1
:expr(sub(Str7,1,2→Y
:expr(sub(Str7,3,2→X
:expr(sub(Str7,5,length(Str7)-4→PMT
:0
:Repeat max(Ans={21,105,22
:max(U,min(V,PMT+(Ans=26)+10(Ans=25)-(Ans=24)-10(Ans=34→PMT
:Output(Y,X,"    
:Output(Y,X,PMT
:1→C/Y
:Repeat Ans
:prgmXTEMP010
:getKey→K
:End
:End
:DelVar Str7PMT→X
:Return
:Lbl 2
:expr(sub(Str7,1,1→X
:Input Str7
:If X:Then
:"expr(Str7
:Asm(prgmXTEMP015
:End
Generated by SourceCoder, © 2005 Cemetech
Insanity wrote:
That weird small 'E' == the 2<sup>nd</sup>-Comma 'E' (whatever the heck it's called).

Exponent (for scientific notation).

BASIC Code wrote:
:Ans→Str7
A:expr(sub(Ans,1,1→W
B:sub(Str7,2,length(Str7)-1→Str7
C:W
:If Ans=1
:Goto 1
:If Ans=2
:Goto 2
...etc


Space optimization: Switch lines A and B and remove line C, and take out the " →W " from line A. This puts that value in Ans without using the W variable, which only gets deleted later. Saves 4 bytes.
  
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 1 of 1
» 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