Well, today I made a text viewing program. It doesn't edit, but here's essentially how it works.

A really long string is stored to Str0 with the following format.

"TEXT_FILE_NAME DATE_CREATED AUTHOR_NAME SUMMARY 000000?? TEXT"

The text file name has 16 slots, the date created is in format 09.12.2008, author name has 23 slots, summary has 92 slots and the zeroes are for some features I plan to implement later (section-based navigation, line breaks etc.)

Now what it does is take your spot, X, and do
Text(8,0,sub(Str0,X,23)
Text(14,0,sub(Str0(X+23),23
and so on until it gets to the ending line. 207 letters are rendered at a time (the graph screen's full capacity with full-width letters).

ISSUES: Spaces are only one pixel wide, so lines with spaces aren't filling the screen.

Sorry, but something just came up, I have to go but I'll be back soon.
Back.

Anyway, I'm encountering some problems with the program. Namely, that it sucks.

Issues to be tackled include rendering the text until the end of the line (rather than a flat 23 characters), as the graph font is non-fixed width, as well as the other tokens like sin( that take up 4 characters in text but only come up as one element of the string.

Another issue is the problem of the files themselves. Currently I have ZZTIX001, ZZTIX002, and ZZTIX003, all of which consist of storing the file's contents to Str0 and running PrgmTEXTREAD. This is bad because it takes up a program for every file, the entire a thing can be deleted with a single mis-push of CLEAR, and can't be archived without majorly screwing everything up. Also, it's currently impossible to access really long-a strings (for example if you were to store a book) that would take up the entire RAM. Can't break them in half, there's only 10 strings. A list would be so much better for storing these kinds of things but they can only have 999 elements and they can't store letters.

Finally, the section jumping feature has me vexed. It would be obvious to have a special character (one that wouldn't be used for anything else) represent a section, however I run into problems regarding not rendering this character with the rest of the string (fex displaying %SECTION ONE instead of SECTION ONE where % is the character). And determining which section you're currently at.

EDIT: I've implemented a FIND feature, which is pretty simple and locates occurences of a given string in the file. It can also count the number of occurences of said string in the entire file from any given point. This is nice and all, but the program's still buggy.

EDIT again: The header information isn't intelligently interpreted. Fex, the first N characters will be interpreted as the file name no matter what. And the next M numbers will be interpreted as the author, and so on. One misstep and the whole program could be off. A character to represent "this section is over" would be nice but I'm also having trouble with that.

I expect to be able to upload a beta at some point soon, perhaps you guys could help. Or maybe this is all just way over my head, and I should learn Asm?

Halp!
If this is over your head, assembly is going to be WAY over your head. Can you post up some code excerpts of the offending sections that aren't working properly for us to take a look at?
KermMartian wrote:
If this is over your head, assembly is going to be WAY over your head. Can you post up some code excerpts of the offending sections that aren't working properly for us to take a look at?


Well, it's not the programming itself that's over my head, it's the fact that I'm trying to make an application that goes way beyond the limitations of TI-BASIC.

EDIT: It's not that anything's working incorrectly (e.g. in a way other than I would expect it to from my commands), it's just that I can't figure a way around certain roadblocks using TI-BASIC without taking up an obscenely huge amount of memory.
...We've already got DocDE and notfolio, FlameViper. It's unlikely you'll top them in BASIC.
Aeromax wrote:
KermMartian wrote:
If this is over your head, assembly is going to be WAY over your head. Can you post up some code excerpts of the offending sections that aren't working properly for us to take a look at?


Well, it's not the programming itself that's over my head, it's the fact that I'm trying to make an application that goes way beyond the limitations of TI-BASIC.

EDIT: It's not that anything's working incorrectly (e.g. in a way other than I would expect it to from my commands), it's just that I can't figure a way around certain roadblocks using TI-BASIC without taking up an obscenely huge amount of memory.


Not to be pessemistic...but a while back I tried the whole "BASIC Text Editor" thing. Mine worked just fine, but it was useless because they do take an exaggerated amount of memory and are not very useful anyway. But if you must do it, then do it.
I don't ridicule it as a project; a text editor is an important way to learn about using string and string functions more efficiently, but it requires some thinking outside the box, as Aeromax noted. For the font-width issue, you can restrict what characters the user can type, assume all characters are 3+1px except for spaces, which are 1 px, periods, which are 1+1px, and commas and parentheses, which are 2+1px.
1.) It's not a waste of effort... all BASIC text editors CAN be pretty sweet =D plus a line-viewer is even easier...


Code:
:Input":",String1
:ClrHome
:iPart(length(String1)/16)+1-->Z
:1-->B
:(Z>8)(8-Z)+Z-->C
:While 1
:Output(sub(String1+String1,16B-15,16C
:0:While not(Ans):getkey:End:Ans-->A
:(A=34)-(A=25)+B-->B
:Z(B=0)-Z(B=Z+1)+B-->B
:End


I would suggest working in the homescreen, at least initially (largely so you can take advantage of the Output command).

Once you have the fundamental code running, you can fairly easily move it to the graphscreen by creating a short loop which will display all the lines, alike Output.

*EDIT*
ugh google Chrome seems to be having some trouble editing text...it fails to clear the remnants of text once portions of the original text have been deleted =([/code]
I have the program here on my computer but I don't see a way to upload files to the topic...?
Aeromax wrote:
I have the program here on my computer but I don't see a way to upload files to the topic...?
Post the code, or submit it to the archives as a beta, or Rapidshare it.
KermMartian wrote:
Aeromax wrote:
I have the program here on my computer but I don't see a way to upload files to the topic...?
Post the code, or submit it to the archives as a beta, or Rapidshare it.


Oh, durf. Here it is.


Code:

  ::".TIX INTERPRETER V0.9"
:Lbl AA
:0→S
:0→Xmin:0→Ymin:94→Xmax:62→YMax:CoordOn:GridOff:AxesOff:ClrDraw:ClrHome
:sub(Str0,1,16)→Str1
:sub(Str0,17,10)→Str2
:sub(Str0,27,23)→Str3
:sub(Str0,50,23)→Str4
:sub(Str0,73,23)→Str5
:sub(Str0,96,23)→Str6
:sub(Str0,119,23)→Str7
:sub(Str0,152,3)→U
:length(Str0)→W
:W-150→W
:W/207→W
:If fPart(W)≠0
:iPart(W)+1→W
:Text(0,0,Str1,"  XXX/XXX"
:Horizontal(55
:Text(8,0,"DATE: ",Str2,"  ","PAGES: ",W
:Line(55,47,55,55
:Horizontal(47
:Text(16,0,Str3
:Horizontal(39
:Text(24,0,Str4
:Text(30,0,Str5
:Text(36,0,Str6
:Text(42,0,Str7
:Horizontal(13
:"RETURNACCESSJUMPTO"→Str9
:1→U
:For(θ,2,66,32
:sub(Str9,U,6)→Str2
:Text(52,(θ+2),Str2
:Line(θ,3,(θ+26),3
:Line(θ,11,(θ+26),11
:Line(θ,3,θ,11
:Line((θ+26),3,(θ+26),11
:Line((θ+13),3,(θ+13),0
:U+6→U
:1→X
:End
:Repeat getKey:End
:Lbl AC
:getKey→Z
:If Z=11 or Z=12
:Stop
:If Z=13
:Goto AD
:If Z=14 or Z=15
:Goto AE
:Goto AC
:Lbl AD
:1→S
:sub(Str0,147,1)→Str2
:sub(Str0,148,1)→Str3
:sub(Str0,149,1)→Str4
:length(Str0)→U
:U-150→U
:sub(Str0,150,U)→Str9
:Lbl BA
:ClrDraw
:length(Str9)→W
:W/207→W
:If fPart(W)≠0
:iPart(W)+1→W
:X/207→V
:If fPart(V)≠0
:iPart(V)+1→V
:Text(0,0,Str1
:Text(0,66,"---/---"
:Text(0,66,V)
:Text(0,82,W)
:Horizontal(55
:Line(64,55,64,62
:Text(8,0,sub(Str9,X,23)
:Text(14,0,sub(Str9,(X+23),23)
:Text(20,0,sub(Str9,(X+46),23)
:Text(26,0,sub(Str9,(X+69),23)
:Text(32,0,sub(Str9,(X+92),23)
:Text(38,0,sub(Str9,(X+115),23)
:Text(44,0,sub(Str9,(X+138),23)
:Text(50,0,sub(Str9,(X+161),23)
:Text(56,0,sub(Str9,(X+184),24)
:Lbl BB
:Repeat Z≠0
:getKey→Z
:End
:If Z=21
:Menu("NAVIGATION MENU","KEEP READING",BC,"PROGRAM INFO",AA,"MAIN MENU",BD,"SKIP TO...",AE,"FIND...",AF,"COUNT...",AG
:length(Str9)→R
:R-207→R
:If Z=11
:1→X
:If Z=12
:(X-207)→X
:If Z=13
:Goto AE
:If Z=14
:(X+207)→X
:If Z=15
:R→X
:If Z=24
:X-1→X
:If Z=26
:X+1→X
:If Z=25
:X-23→X
:If Z=34
:X+23→X
:Lbl BC
:If X>R
:R→X
:If X<1
:1→X
:Goto BA
:Lbl AE
:Menu("QUICK PAGE JUMP","JUMP TO PAGE",CA,"JUMP TO LINE",CB,"JUMP TO CHAR",CC,"RETURN",BC
:Lbl CA
:207→U
:Goto CD
:Lbl CB
:23→U
:Goto CD
:Lbl CC
:1→U
:Goto CD
:Lbl CD
:ClrHome
:Disp "CURRENT LOCATION"
:Disp "PAGE : -----"
:Disp "LINE : -----"
:Disp "CHAR : -----"
:Output(2,8,iPart(X/207)
:Output(3,8,iPart(X/23)
:Output(4,8,X
:Input "----------------",T
:T*U→X
:If S=1
:Goto BC
:If S=0
:Goto AD
:Lbl AF
:ClrHome
:Input "FINDIN DOCUMENT:",Str8
:inString(Str9,Str8,X)→U
:If U≠0
:U→X
:Goto BC
:Lbl AG
:ClrHome
:Input "COUNT INSTANCES:",Str8
:1→U
:0→S
:Lbl AH
:inString(Str9,Str8,U)→T
:If T≠0
:Then
:S+1→S
:(T+1)→U
:Goto AH
:End
:If T=0
:Then
:ClrHome
:Disp "INSTANCES OF:",Str8,S
:Repeat getKey:End
:ClrHome
:Goto BC


Here's a simple test file that shows how a header/information work:


Code:

::"TESTFILE.TIX
:"TEST-FILE-------09.12.2008AEROMAX----------------FILLER-TO-TEST-THE--TIX-READER-CREATED-BY-AEROMAX-ON-SEPTEMBER-12--2008--HEADER-LENGTH-150--000000<>SECTION ONE DOLOR SIT AMET. CONSECUTOR, ADIPISCING ELIT. A BUNCH OF PSEUDOLATIN CRAP GOES HERE IF I RECALL CORRECTLY, BUT I FORGET. WHAT IS LOVE? BABY DON'T HURT ME. DON'T HURT ME. NO MORE. SO NOW I THINK I AM JUST GOING TO TYPE A BUNCH OF RANDOM CRAP TO MAKE THIS LONGER. THERE, THAT SHOULD DO. OR WILL IT? DUN DUN DUUUNNNNN. MAN, I REALLY HOPE THIS PROGRAM WORKS, BECAUSE IF IT DOESN'T I'M GOING TO BE SUPER-PISSED."→Str0
:prgmTEXTREAD
Gah, why do you people always insist on cropping the SC2 copyright text out of the output? Sad
Ok, that code is TOTALLY Surprised and kills kittens and puppies.

Omg, seriously.. >.<


Code:
:Repeat getKey:End
:Lbl AC
:getKey→Z
:If Z=11 or Z=12
:Stop
:If Z=13
:Goto AD
:If Z=14 or Z=15
:Goto AE
:Goto AC



NONONONONONONO, BAD programmer, no cookies for you. Lbls are bad for your health. They can cause bad eye sight, severe migraines, stomach problems, and poor gas mileage.


The loop you are using there is SLOW. The reasoning for this is because everytime you run a Goto, it starts at the top of the program and works its way down til it finds it. Utilize a While loop instead.


Code:
0->Z
While Z>10 and Z<16
getKey->Z
End
If Z=11 or Z=12
Stop
If Z=13
Goto AD
If Z=14 or Z=15
Goto AE


That will speed that up a bit.


And why are you tying up so many Str# variables??!


Code:
:Text(8,0,"DATE: ",Str2,"  ","PAGES: ",W

-TO-

:Text(8,0,"DATE: "+sub(Str1,17,10)+"  PAGES: ",W


Works just fine, and speeds things up because you are not looking to waste that bit of time storing to additional strings, and it saves room. The same things can be applied to the rest of the strings you have up there.

Make the changes to the code, and repost with the new stuff, and we can see where else we can help hack off unwanted coding, etc... Razz
Also, Return is better than Stop is almost all circumstances (especially with shells), so use it instead of Stop.
Actually... I think we need to make the program GO before it will STOP. Razz

But yeah, that is generally a good idea, to use Return instead of Stop.

There are numerous other things, I am sure you can do...
Oh wowzers, I thought using a Lbl was faster than a long block of code.

But yeah, the obscene amount of strings used is mostly because I was doing this entire thing on my calculator (mostly without my notes), so I could just-a-seasily redo it in SC, but I've also got a lot of stuff going on in life, so that'll have to wait until stuff happens.
Nope, I have found a way to use While loops to completely replace Lbl Goto stuff, but still get the same effect while maintaining speed. It is pretty nifty. Smile
I realize that this makes me a total douche, but anyways I wrote a quick text-viewer/scroller thingy utilizing codex to do fast, smooth scrolling...


Code:
:13:Asm(prgmCodex
:25-->R
:8-->L
:iPart(length(Str0)/R)+1-->Z
:sub(Str0+"                                                      ",1,RZ)-->Str1
:1-->B
:(Z>L)(L-Z)+Z-->C
:For(N,1,C
:Text(7N-5,4,sub(Str1,RN-R+1,R
:End
:While 1
:0:While not(Ans:getKey:End:Ans-->A
:B-->D
:(A=34)-(A=25)+B-->B
:(B=0)-(B=Z+1)+B-->B
:If B<>D and Z<>C
:Then
:For( N,1,7
:(B=D-1)+2
:Asm(prgmCodex
:End
:Text(2(B=D-1)+(7L-5)(B<>D-1),4,sub(Str1,RB-R+1,R
:End
:End


1.) This program will scroll/display Str0
2.) "<>" is "not equal to"
3.) R is the line length, while L is the number of lines to display. Adjust at will =D
4.) I'll try to upload a copy of this program somewhere as soon as I can get to my link cable....
5.) Kerm, I haven't been cropping out the SC2 copyright text...I've been typing in this code manually....
6.) Aeromax, you should consider using Celtic2 to store your "text files" in a program rather than in strings...
Very nice, rthprog, good use of Codex. I can tell you're not using SC2 because you have <> instead of the =/= symbol. Smile
thanks Kerm =D


Code:
:13:Asm(prgmCodex
:27-->R
:9-->L
:iPart(length(Str0)/R)+1-->Z
:sub(Str0+"                                                      ",1,RZ)-->Str1
:1-->B
:(Z>L)(L-Z)+Z-->C
:For(N,1,C
:Text(7N-6,4,sub(Str1,RN-R+1,R
:End
:While 1
:B-->D
:0:Repeat(Ans:getKey:End:
:(Ans=34)-(Ans=25)+B-->B
:(B=0)-(B=Z+1)+B-->B
:If B<>D and Z<>C
:Then
:For( N,1,7
:(B=D-1)+2
:Asm(prgmCodex
:End
:Text((B=D-1)+(7L-6)(B<>D-1),4,sub(Str1,RB-R+1,R
:End
:End


I just made some minor modifications that fix some bugs (namely the stray pixels when scrolling up) and save some space =D I'm wondering if it would be advantageous to let the user scroll, and update lines once no buttons are being pressed...making scrolling much smoother and a bit faster....

In addition, perhaps storing the image of the lines and overlaying a secondary image which is removed when scrolling would allow such things as sprites, menus, etc...
  
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 2
» 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