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:
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!
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!