I have been working on a simple program that will allow programmers to easily align their text on the homescreen. Center and right aligning will center/right align the inputted text, and the custom aligning for text allows the user to move the text with the left and right arrows. Also, pressing 1, 2, and 3 are hotkeys for align left, align center, and align right, respectively.

Code:
ClrHome
Output(1,1,"Operation For Text
Output(3,2,"Center
Output(4,2,"Align Right
Output(5,2,"Align Custom
Output(6,2,"Quit
Output(3,1,">
3→Q
Repeat K=21 or K=105
getKey→K
If Ans=25 or Ans=34
Then
Output(Q,1," "
Q-(K=25)+(K=34)→Q
If Q=2:6→Q
If Q=7:3→Q
Output(Q,1,">
End
End
If Q=6
Then
ClrHome
Return
End
If Q=3:"Center Text→Str2
If Q=4:"Align Right→Str2
If Q=5:"Align Custom→Str2
Repeat L<27
ClrHome
Disp "--Align Home Screen Text--",""
Input "Your text:",Str1
length(Str1)→L
If L>26:Then
ClrHome
Disp "Less than 27 characters,","please!"
Pause
End:End
ClrHome
If Q=3:iPart(14-.5L)→A
If Q=4:27-L→A
If Q=5:1→A
For(X,1,26
Output(9,X,"-
End
Output(1,A,Str1
Output(4,1,"Use Output(…,  ,Your text
Output(4,14,A
Output(6,1,"Your text is stored in    Str1.
Output(10,iPart((14-length(Str2)/2)),Str2
If Q=5:Then
Output(8,7,"Press <CLEAR>
0→K
Repeat Ans=45
If K=92 or K=93 or K=94:Then
For(A,1,26
Output(1,A,"
End
(K=92)→A
If K=93:int(14-.5L)→A
If K=94:27-L→A
Output(1,A,Str1
Output(4,15,"
Output(4,14,A
End
A→V
A+(K=26)-(K=24)→A
If A>(27-L)
27-L→A
If A=0:1→A
If A≠V:Then
Output(1,V,"
Output(1,V+L-1,"
Output(1,A,Str1
Output(4,15,"
Output(4,14,A
End
getKey→K
End:End
Output(8,7,"Press <ENTER>
Pause
ClrHome
DelVar Str2DelVar ADelVar BDelVar KDelVar LDelVar QDelVar VDelVar X


The code works without flaws ... mostly. If I input a token like Str2 or angle(, because I use length(Str1) to determine how many characters are in the string, it does not work. This happens because length( counts the number of tokens in a string, not the amount of space they take up when displayed on the screen (for example, Str1 would be 4 and angle( would be 6). Is there a way for me to fix this problem, or should I just advise users in the readme not to input any tokens with more than one character or it will not work? Thanks!
You would need a small ASM stub program that calls the OS call that determines the width, in characters, of a token. It wouldn't be terribly difficult, so I'd recommend going that route if you want this to be as robust a program as possible. The function in question is _GetTokLen:
Code:
_GetTokLen      equ 4591h ;input: hl=pointer to token. output: a=lenght of string, hl=pointer to string on page 1
Does this help?
Michael2_3B wrote:
I'm fairly confident that that refers to the width of strings on the monochrome calculators' graphscreen, which is less than helpful for this homescreen application. Smile
Michael2_3B wrote:

I made my program for the TI-84+CSE/CE, so I do not think those will help me.

Kerm: I am sorry, but I have no idea how to make an ASM program. I want to learn, but I don't know how. I have seen the 28 days to ASM thing, but I don't have a monochrome calculator and get confused.

Also, I like to keep my programs free of subprograms (unless absolutely necessary) because if the subprogram gets deleted or something, it wouldn't work. Are you sure there is no other way, and do I just copy and paste that code into SourceCoder or something to make the program? Then, will the subprogram return the value in Ans?

Edit: Could someone please help me with this by creating the ASM program that will count the number of characters in Str1 for me? This is for an eZ80 calculator.
Couldn't you just have the text start at 1,1 and have to user move the text to the correct spot that they want, then giv them those variables?
If their text is only one or two characters long, it would make it difficult for them to tell when the text is centered, and centering text was the original reason for my making of this program (which expanded slightly). Also, if they input more than 26 characters, some text will get cut off going to the next line, like:

Hello this is my text Ceme
tech
That is true, but if worse comes to worse, you are going to need to to that, I think.
  
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