I am trying to make an input-like thing on the graph screen where numbers, capital and lowercase letters could be inputted. In my code, there are mem leaks but I'd like to get the program working before I move on to mem leaks and optimizations. Here is my code, it doesn't work (specifically the ALPHA thing to change from numbers to letters) hopefully someone sees why

Code:
" ->Str5
" ->Str3
"Aa1->Str4
1->W
Lbl A
Text(25,5,sub(Str4,W,1
Text(10,5,Str5
If W!=3:Then
Repeat Ans>34 and min(Ans!={44,45 or Ans=31
getKey
End
If Ans=31:Then
3fPart(W/3)+1->W
Goto A
End
If W=1
sub("ABC  DEFGHIJKLMNOPQRSTUVWXYZ",Ans-5int(.1Ans+4),1->Str3
If W=2
sub("abc  defghijklmnopqrstuvwxyz",Ans-5int(.1Ans+4),1->Str3
End
If W=3:Then
Repeat Ans>71 and min(Ans!={75,81,85,91,95,103,104 or Ans=31
getKey
End
If Ans=31:Then
3fPart(W/3)+1->W
Goto A
End
sub("789  456  123  0",Ans-36-5int(.1Ans),1->Str3
End
Str5+Str3->Str5
Goto A

Here is a graph showing how W should loop through the numbers 1 to 3
I would recommend taking a look at some of the code I have in BasicNote. Also, this may help you: http://tibasicdev.wikidot.com/custominput
for your key to letter conversion, how bout this instead?

Code:
K-20-5int(.1K

Also, it looks like you're doing a weird method of looping W from 1 to 3 and back again. it works, but... it's strange. this is what I would do:

Code:
W+1-3(W=3->W
I've went along and had a look at all 3 custom text inputs on tibascdev, but none of them include lower-case letters, upper-case letters and numbers, I did try to play around with one of them (the one with numbers and upper-case letters) in order to add on numbers, but I am once again faced with an unincrementing variable D:
here is the 2nd sad attempt...

Code:
ClrDraw
DelVar A15->B
Text(1,82,"         
Text(0,82," LET
" ->Str1
Repeat max(M={45,105,21
~5->C
Repeat M=23 or max(Ans={21,45,105}) or (not(A)M>40 and not(A)M<95 and M!=44) or max(AAns={92,93,94,102,82,83,84,72,73,74
C+1-10(C>4->C
Text(29,B,sub(" [",1+(Ans>0),1
Text(29,B+1,"
If M=31
Then
A+1-3(A=2
Text(0,83,sub("LET NUM  let ",4A+1,4
End
getKey->M
End
If min(M!={21,105,45,23
Then
If A=1
Then
sub("0123456789",27-3int(.1M)+10fPart(.1M)+2(M=102),1
Text(29,B,Ans
Str1+Ans->Str1
B+8->B
Else
If not(A
sub("ABC  DEFGHIJKLMNOPQRSTUVWXYZtheta",M-5int(.1M)-20,1
If A=2
sub("abc  defghijklmnopqrstuvwxyztheta",M-5int(.1M)-20,1
Text(29,B,Ans
Str1+Ans->Str1
B+8->B
End
Else
If M=23 and 1<length(Str1
Then
B-8->B
Text(29,Ans,"     
sub(Str1,1,length(Str1)-1->Str1
End
End
End

Oh and michael, but my weird method is smaller Razz
Now you've got me curious on making something like this myself.. Might give me something to do, anyways Very Happy

http://www.ticalc.org/archives/files/fileinfo/363/36335.html

Was my last attempt at such a thing.

I also did this with the Prizm:

https://www.cemetech.net/programs/index.php?mode=file&path=/prizm/programs/Key2Text.zip

Very Happy
tifreak8x wrote:
Now you've got me curious on making something like this myself.. Might give me something to do, anyways Very Happy

http://www.ticalc.org/archives/files/fileinfo/363/36335.html

Was my last attempt at such a thing.

I also did this with the Prizm:

https://www.cemetech.net/programs/index.php?mode=file&path=/prizm/programs/Key2Text.zip

Very Happy

Woot! Good luck! You'll need it Razz
wait, no you won't xD
This is for monochrome, so it won't work on CSE, however I'll still put it here. This is the title input for BasicNote, however it is not as advanced as the note input in the text editor, because, well, it doesn't need to be. I could add the different ALPHA support, but I didn't. I might though. You can see my text editor code in BasicNote if you need to.

Also, if you have any specific questions, I'd be happy to help you know Smile

Code:
" "->Str6
Repeat length(Str6)>1 and (K=34 or K=105   //repeat until something has been entered and ENTER or DOWN is pressed
If 1=length(Str6
Text(0,1,"ENTER TITLE"   //if nothing has been entered, display this. obviously not needed in yours
Repeat Ans
getKey->K
End
Ans-20-5int(.1Ans
If 12>length(Str6) and 0<Ans and Ans<29 and K!=44 and K!=45:Then   //11 is my length limit for the title. the rest is validating the key press
If 1=length(Str6
Text(0,1,"                                            "
Str6+sub("ABC  DEFGHIJKLMNOPQRSTUVWXYZ",Ans,1->Str6
End
If K=23 and length(Str6)>1:Then   //if DEL pressed and something has been entered
sub(Str6,1,length(Str6)-1->Str6
Text(0,1,Str6+"   "
End
If K=45:Then   //if CLEAR pressed, delete entire title
" "->Str6
Text(0,1,"                                            "
End
Text(0,1,Str6
End:End

extra, unneeded quotes added for color correction
So, I spent about 20 minutes this morning while I was waiting for newspapers to arrive, to work on this problem.




Code:
ClrDraw:AxesOff
1→W:1→U
" "→Str2
While W=1
Text(17,0,Str2
Text(0,250,sub("Aa#",U,1
getKey→K
U+1(K=31)(U<4)→U
If U=4:1→U
If K=31:Text(0,250,"     
If K>40
Str2+sub("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz              789  456  123  0",(K-(40+7(K>50)+5(K>60)+5(K>70)+5(K>80)+5(K>90)+5(K>100)))+26(U>1)+26(U>2),1)→Str2
End


Program is 320 bytes in size. I know the sub( bit could be shrunk down, but I didn't get that far, and it does work flawlessly.
tifreak8x wrote:
So, I spent about 20 minutes this morning while I was waiting for newspapers to arrive, to work on this problem.




Code:
ClrDraw:AxesOff
1→W:1→U
" "→Str2
While W=1
Text(17,0,Str2
Text(0,250,sub("Aa#",U,1
getKey→K
U+1(K=31)(U<4)→U
If U=4:1→U
If K=31:Text(0,250,"     
If K>40
Str2+sub("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz              789  456  123  0",(K-(40+7(K>50)+5(K>60)+5(K>70)+5(K>80)+5(K>90)+5(K>100)))+26(U>1)+26(U>2),1)→Str2
End


Program is 320 bytes in size. I know the sub( bit could be shrunk down, but I didn't get that far, and it does work flawlessly.

wow, that's actually incredibly small considering the other routines on tibasicdev don't allow all three modes and are larger than this. I can't really think of how the sub( bit could be shrunk down although I do see a correlation between the numbers, maybe lirto will find a way Razz anyways, thank you, I will be using this one, you should consider adding it to tibasicdev as it seems like it would be a fairly useful routine and that just seems like the place to put fairly useful routines Razz

Code:
U+1(K=31)(U<4)→U
If U=4:1→U

can be

Code:
U+(K=31)-4int(U/4→U
Michael2_3B wrote:

Code:
U+1(K=31)(U<4)→U
If U=4:1→U

can be

Code:
U+(K=31)-4int(U/4→U

ORRRR

Code:
3fPart(U/3)+1->U

I played around with the routine a little, Added a line that deletes the initial space and the one left behind from when you press enter, also since you had no characters in the string for the keycodes 102 through 105, I added those in as well becuase it would throw a dim error if you pressed on those while in # mode. As you might have noticed, I also put the keycodes 45 and 23 (clear and Del) in there as well, since I am planning on implementing those features Smile Maybe the use of the Ans token would be possible instead of the K, but I haven't tried that.

Code:
1->U
" ->Str2
Repeat max(K={105,45,23
Text(17,0,Str2
Text(0,250,sub("Aa#",U,1
getKey->K
If K=31:Then
Text(0,256," 
3fPart(U/3)+1->U
End
If K>40
Str2+sub("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz              789  456  123  0.~ ",(K-(40+7(K>50)+5(K>60)+5(K>70)+5(K>80)+5(K>90)+5(K>100)))+26(U>1)+26(U>2),1->Str2
End
sub(Str2,2,length(Str2)-2->Str2
I have a very specific style of coding, which mostly includes writing the simplest code that should work, and if it doesn't, allows me to (usually) easily find the bug. Hence the lack of optimizations that could have been put in.

I also only spent 20 minutes on this to make it work. :p I was mostly concerned with it detecting the keys and putting up the proper character. Mostly taken as a challenge to try to get back into programming again.
  
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