About a decade ago, Arthur O'Dwyer published a BASIC program to TiCalc called Castle Adventure. I picked this program up, and decided I really liked it. This was when I had my Ti84+SE, which you know has a monochrome screen. I want to be able to port the program to the CE, which has a color screen. As you might imagine there are many many times where the image does not line up where it is supposed to. (Later I will post some before and after photos). I've been fixing those errors up for a while now, and I'm about to start adding in some color. The problem is O'Dwyer uses Ans extremely often. He actually uses it 78 times in a program that is 5kB and a little over half made of text. I'm just going to post some code bits maybe you guys can help me understand what in the world he is doing.



Code:
For(A,length(Ans),0:End
Str9+Ans+":"->Str9
length(Ans->B
DelVar CFor(A,B-A,B
   1+C->C
   inString(Str9,":",A
   If A+23>=Ans:Then
      Ans->A
      Else
      A+23
   While " "!=sub(Str9,Ans,1:Ans-1:End
      Ans->A
      sub(Str9,1,Ans-1)+":"+sub(Str9,Ans+1,B-Ans->Str9
   End
End

Ans is a rather large string at this point.
Looking at the very first line, if the end value is 0, wouldn't this just end immediately? Like some kind of weird delay?
It seems to me something like word-wrapping or so. The last part searches for the first space backwards, and I think the first part of the For-loop sets the braking index or so. I'm not though, so don't blame me if I'm wrong Razz
Oh hey you're right! Thanks for saying the space thing because I wouldn't have recognized that. He puts in a colon to recognize a line break, which later he calls out. The full program scrolls about 6 lines of text upwards in case you were wondering.
---
Also, I still wouldn't mind even if you had no clue what the thing is. Any help at all is appreciated very much. Very Happy
Let me try to explain more Smile
It seems Str9 is the standard string, for displaying a bunch of text, with the braking index of ":". Thus, the colon would be an enter. Now it adds a large string in Ans + a colon after it, which implies that there are coming new lines. inString(Str9,":",A will point you to the last colon in Str9, NOT WITH ANS INCLUDED. Now, it searches ANS for colons. If there appears a colon within the next 23 charaters (the amount of characters you can display at a line), it updates the po inter. If not, it will search ANS to the last space, and replace that with a colon to indicate a new line.
Hope this helps a bit more Smile
  
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