Jump to content



Photo
- - - - -

Text Reader (and Later, Editor) (long Code)


  • Please log in to reply
22 replies to this topic

#1 tutti

tutti

    Casio Addict

  • Members
  • PipPipPip
  • 65 posts

  • Calculators:
    FX-9860G SD

Posted 12 May 2005 - 11:59 AM

I'm trying to make a text editor for my calculator. Currently, I've got the reader and the character set made, and I was wondering if there is a way to make any of these run faster.

Reader:
Lbl A
1->E
1->X
1->Y
1->Z
ClrText
"Read which file"?->F
F>6 Or F<0=>Goto A
F=1=>File1
F=2=>File2
F=3=>File3
F=4=>File4
F=5=>File5
F=6=>File6
ClrText
Lbl B
Prog "TEXTCODE"
X+1->X
X=22 Or N=2=>Y+1->Y
X=22 Or N=2=>1->X
Z+1->Z
1->N
E=2 Or Z=49=>Goto C
Goto B
Lbl C
Getkey->K
K=31=>Goto A
Goto C

Character set:
List 1[Z]=0=>Locate X,Y,"A"
List 1[Z]=1=>Locate X,Y,"B"
List 1[Z]=2=>Locate X,Y,"C"
List 1[Z]=3=>Locate X,Y,"D"
List 1[Z]=4=>Locate X,Y,"E"
List 1[Z]=5=>Locate X,Y,"F"
List 1[Z]=6=>Locate X,Y,"G"
List 1[Z]=7=>Locate X,Y,"H"
List 1[Z]=8=>Locate X,Y,"I"
List 1[Z]=9=>Locate X,Y,"J"
List 1[Z]=10=>Locate X,Y,"K"
List 1[Z]=11=>Locate X,Y,"L"
List 1[Z]=12=>Locate X,Y,"M"
List 1[Z]=13=>Locate X,Y,"N"
List 1[Z]=14=>Locate X,Y,"O"
List 1[Z]=15=>Locate X,Y,"P"
List 1[Z]=16=>Locate X,Y,"Q"
List 1[Z]=17=>Locate X,Y,"R"
List 1[Z]=18=>Locate X,Y,"S"
List 1[Z]=19=>Locate X,Y,"T"
List 1[Z]=20=>Locate X,Y,"U"
List 1[Z]=21=>Locate X,Y,"V"
List 1[Z]=22=>Locate X,Y,"W"
List 1[Z]=23=>Locate X,Y,"X"
List 1[Z]=24=>Locate X,Y,"Y"
List 1[Z]=25=>Locate X,Y,"Z"
List 1[Z]=26=>Locate X,Y,"a"
List 1[Z]=27=>Locate X,Y,"b"
List 1[Z]=28=>Locate X,Y,"c"
List 1[Z]=29=>Locate X,Y,"d"
List 1[Z]=30=>Locate X,Y,"e"
List 1[Z]=31=>Locate X,Y,"f"
List 1[Z]=32=>Locate X,Y,"g"
List 1[Z]=33=>Locate X,Y,"h"
List 1[Z]=34=>Locate X,Y,"i"
List 1[Z]=35=>Locate X,Y,"j"
List 1[Z]=36=>Locate X,Y,"k"
List 1[Z]=37=>Locate X,Y,"l"
List 1[Z]=38=>Locate X,Y,"m"
List 1[Z]=39=>Locate X,Y,"n"
List 1[Z]=40=>Locate X,Y,"o"
List 1[Z]=41=>Locate X,Y,"p"
List 1[Z]=42=>Locate X,Y,"q"
List 1[Z]=43=>Locate X,Y,"r"
List 1[Z]=44=>Locate X,Y,"s"
List 1[Z]=45=>Locate X,Y,"t"
List 1[Z]=46=>Locate X,Y,"u"
List 1[Z]=47=>Locate X,Y,"v"
List 1[Z]=48=>Locate X,Y,"w"
List 1[Z]=49=>Locate X,Y,"x"
List 1[Z]=50=>Locate X,Y,"y"
List 1[Z]=51=>Locate X,Y,"z"
List 1[Z]=52=>Locate X,Y,"1"
List 1[Z]=53=>Locate X,Y,"2"
List 1[Z]=54=>Locate X,Y,"3"
List 1[Z]=55=>Locate X,Y,"4"
List 1[Z]=56=>Locate X,Y,"5"
List 1[Z]=57=>Locate X,Y,"6"
List 1[Z]=58=>Locate X,Y,"7"
List 1[Z]=59=>Locate X,Y,"8"
List 1[Z]=60=>Locate X,Y,"9"
List 1[Z]=61=>Locate X,Y,"0"
List 1[Z]=62=>Locate X,Y,"."
List 1[Z]=63=>Locate X,Y,","
List 1[Z]=65=>Locate X,Y,";"
List 1[Z]=66=>Locate X,Y,"!"
List 1[Z]=67=>Locate X,Y,"?"
List 1[Z]=68=>Locate X,Y,"("
List 1[Z]=69=>Locate X,Y,")"
List 1[Z]=70=>Locate X,Y,"{"
List 1[Z]=71=>Locate X,Y,"}"
List 1[Z]=72=>Locate X,Y,"["
List 1[Z]=73=>Locate X,Y,"]"
List 1[Z]=74=>Locate X,Y,"+"
List 1[Z]=75=>Locate X,Y,"-"
List 1[Z]=76=>Locate X,Y,"?"
List 1[Z]=77=>Locate X,Y,"?"
List 1[Z]=78=>Locate X,Y,"^"
List 1[Z]=79=>Locate X,Y,"?"
List 1[Z]=80=>Locate X,Y,"?"
List 1[Z]=81=>Locate X,Y," "
List 1[Z]=83=>Locate X,Y,"="
List 1[Z]=84=>Locate X,Y,"<"
List 1[Z]=85=>Locate X,Y,">"
List 1[Z]=86=>Locate X,Y,"/"
List 1[Z]=88=>Locate X,Y,"@"
List 1[Z]=89=>Locate X,Y,"#"
List 1[Z]=90=>Locate X,Y,"$"
List 1[Z]=92=>Locate X,Y,"&"
List 1[Z]=93=>Locate X,Y,"'"
List 1[Z]=94=>Locate X,Y,"*"
List 1[Z]=95=>Locate X,Y,"?"
List 1[Z]=96=>Locate X,Y,"?"
List 1[Z]=97=>Locate X,Y,"?"
List 1[Z]=98=>2->N
List 1[Z]=99=>2->E

The weird characters near the end come from copy/pasting from FA-123.

First, the reader sets which file to read. Then, it runs the character map once for the first letter, and goes on to the next letter. If the screen is full or it has reached the end, it stops typing.

Anyway, the reader is very slow. Is there anything I can do to make it faster?

PS. Yes, I will make an editor for it too.

#2 huhn_m

huhn_m

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1957 posts
  • Gender:Male
  • Location:Germany / Dresden
  • Interests:Assembler(!!!)
    Computers and Programming
    Operating Systems
    Programmable Calculators
    Maths and everything arround it

  • Calculators:
    FX-82SX / AFX 2.0+ (ROM 1.03) / FX 1.0+ (ROM 1.03)

Posted 12 May 2005 - 02:57 PM

the BASIC interpreter is, due to the slow processor not capable to
do such extensive things. I tried it myself (I wrote an encrypter for the
calc) but it is not fit for "real" editing" :D

#3 tutti

tutti

    Casio Addict

  • Members
  • PipPipPip
  • 65 posts

  • Calculators:
    FX-9860G SD

Posted 12 May 2005 - 06:14 PM

Meh. I can do with the speed it has now, if I have to.

The problem that has appeared now, is writing a working editor.

#4 octobclrnts

octobclrnts

    Casio Freak

  • Members
  • PipPipPipPip
  • 145 posts
  • Location:Pennsylvania, United States
  • Interests:Computers<br />Programming languages<br />Artificial Intelligence<br />Music (clarinet)

  • Calculators:
    Casio CFX 9850GB Plus
    Ti-89 Titanium

Posted 12 May 2005 - 07:36 PM

If I may ask, what is your purpose in writing this editor. If you just need to be able to read and write then you could always just make a program that doesn't execute but is filled with text. But if your purpose is just because you can then all power to you. Some of the greatest things have been accomplished because it was there or they just could (Mt. Everest).

#5 Orwell

Orwell

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 777 posts
  • Gender:Male
  • Location:Paris - France

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 13 May 2005 - 01:44 PM

You should write TEXTCODE like this:
List 1[Z]
Ans=0=>Locate X,Y,"A"
Ans=1=>Locate X,Y,"B"
Ans=2=>Locate X,Y,"C"
Ans=3=>Locate X,Y,"D"
...
It will certainly be faster :)

By the way, Goto's are slow too. Your prog here is quite simple, thus I think you should try to write it without any Goto, it is a good exercise and the speed will increase as well ;)

#6 octobclrnts

octobclrnts

    Casio Freak

  • Members
  • PipPipPipPip
  • 145 posts
  • Location:Pennsylvania, United States
  • Interests:Computers<br />Programming languages<br />Artificial Intelligence<br />Music (clarinet)

  • Calculators:
    Casio CFX 9850GB Plus
    Ti-89 Titanium

Posted 16 May 2005 - 02:02 AM

I believe that Orwell is right. I have read several programming books such as java and c++. They both said that goto is a dangerous command because it can send you anywhere in the code at anytime. It also said you should try to avoid it's use in favor of a loop such as a while, for, do...They are considered safer. Although I know sometimes you just can't do it. Just a friendly hint. ;)

#7 dscoshpe

dscoshpe

    Casio Freak

  • [Legends]
  • PipPipPipPip
  • 185 posts
  • Location:California, USA

  • Calculators:
    AFX 2.0 (v1.00), 9850Ga+, 9800, BE-300 other..

Posted 16 May 2005 - 08:38 AM

You can also try optimizing the jumps and using an "index".

Insert Goto's such that "If Ans > 20 Goto B" etc. And then organize the jumps so that characters that are likely to appear the most have the fewest (or even none) jumps and If's before they are displayed.

- dscoshpe -

#8 Orwell

Orwell

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 777 posts
  • Gender:Male
  • Location:Paris - France

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 16 May 2005 - 12:23 PM

Insert Goto's such that "If Ans > 20 Goto B" etc. And then organize the jumps so that characters that are likely to appear the most have the fewest (or even none) jumps and If's before they are displayed.

Well, this is what you could find in a prog written in asm... It's okay here because we need to optimize speed as much as possible, but it is simply horrible in a high level language (even in basic), so be careful, don't get used to it and in any case avoid using goto's that much ;)

#9 dscoshpe

dscoshpe

    Casio Freak

  • [Legends]
  • PipPipPipPip
  • 185 posts
  • Location:California, USA

  • Calculators:
    AFX 2.0 (v1.00), 9850Ga+, 9800, BE-300 other..

Posted 16 May 2005 - 08:09 PM

Yeah, big If/Then statements would also do what I said, I had forgotten the calculators support them. (I don't deal in Casio basic at all any more)

- dscoshpe -

#10 liquid

liquid

    Wannabe Casio God

  • Members
  • PipPipPip
  • 66 posts
  • Gender:Male
  • Location:NZ

  • Calculators:
    fx 9750 Plus

Posted 06 June 2005 - 12:29 AM

When u get the editor finished, mak sure u post it up, i wanna give it a try.
It would be cool if ya had a "Basic OS" on ur calc with wordedit, excel, and paint, and a custom start menu or desktop,,,,,,,,all the OS for the 9750 ive tried so far r pretty lame as they dont do n'thing, but still amussing.

#11 Lance

Lance

    Newbie

  • Members
  • Pip
  • 6 posts

  • Calculators:
    CFX-9850GB Plus

Posted 06 June 2005 - 04:23 AM

Sorry for sounding dumb, but what exactly does the program do?

#12 dscoshpe

dscoshpe

    Casio Freak

  • [Legends]
  • PipPipPipPip
  • 185 posts
  • Location:California, USA

  • Calculators:
    AFX 2.0 (v1.00), 9850Ga+, 9800, BE-300 other..

Posted 09 June 2005 - 06:14 AM

The code that this thread is about isn't a full program on it's own as presented here. It is just a routine to draw a symbol (A->z) as represented by a number from a list. You can do this to produce dynamic (but slow) text output on a screen.

So, if in the list you have: 12,34,56,68,32,..., etc.. You can say that 34 stands for "R" and so on... By having the variable X and Y setup, you can just say where on the screen you want to print (X,Y) and what symbol (34="R").

You have to do it this way because the calculator has no support in BASIC for strings.

- dscoshpe -

#13 tutti

tutti

    Casio Addict

  • Members
  • PipPipPip
  • 65 posts

  • Calculators:
    FX-9860G SD

Posted 13 June 2005 - 02:39 PM

Whoa, I forgot I even had this here >_<

Meh, I haven't had a chance to work on the program much (I've had a lot of exams and other stuff at school) but it's vacation soon, so I'll be able to do more then.

I'm not as skilled at this as many of you are, so can you tell me how I can avoid the use of Goto? And isn't Goto the best command when I need to call one part of the program from many other parts of it?

And thanks, guys.

#14 Andy.Davies

Andy.Davies

    Forum Ghost

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1547 posts
  • Gender:Male
  • Location:Dorset, England
  • Interests:Age: 18
    Studying: MEng in cybernetics at Reading uni
    Interests: Progaming (VB, VB.Net, C#, Casio Basic)
    Computers UBBD (Using, Building, Breaking &amp; Destroying)
    Gaming (FPS, RTS, RPG)
    Electronics
    Rock Music (Preferably Loud)
    Riley's (Pool &amp; Snooker Bar)
    Driving (Preferably fast)
    Aikedo (Martial Art)

  • Calculators:
    Algebra FX 2.0 ROM 1.01, FX9750G

Posted 13 June 2005 - 06:41 PM

if you need to call one part of a program repeatedly, put the code into a seperateprogram, and use this command in the programmto call it

Prog "NAME"
(replace name with the program name).

in the small programm, dont add anything to the end or it, when it has finnished runnin it will return to the program that called it.

#15 tutti

tutti

    Casio Addict

  • Members
  • PipPipPip
  • 65 posts

  • Calculators:
    FX-9860G SD

Posted 13 June 2005 - 07:37 PM

I know (I actually use that), but with this program, I'd have to use very many little programs, and I'd rather avoid that. Thanks, though.

#16 Andy.Davies

Andy.Davies

    Forum Ghost

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1547 posts
  • Gender:Male
  • Location:Dorset, England
  • Interests:Age: 18
    Studying: MEng in cybernetics at Reading uni
    Interests: Progaming (VB, VB.Net, C#, Casio Basic)
    Computers UBBD (Using, Building, Breaking &amp; Destroying)
    Gaming (FPS, RTS, RPG)
    Electronics
    Rock Music (Preferably Loud)
    Riley's (Pool &amp; Snooker Bar)
    Driving (Preferably fast)
    Aikedo (Martial Art)

  • Calculators:
    Algebra FX 2.0 ROM 1.01, FX9750G

Posted 13 June 2005 - 11:58 PM

ever thought of a subroutine program?

MAIN PROG:
0->A
PRGM "SUBS"
1->A
PRGM "SUBS"
2->A
PRGM "SUBS"


SUBS:

If A = 0 then
'Code
Else If A = 1 Then
'Code
Else If A = 2 Then
'Code
End If
End If
End If

This method can be used quite efficently, all you have to do is designate a variable(s) as a preloader(s), i usually use Theata ( :theta: ) and Little r ( :r: )

hope that helps you :)

#17 Orwell

Orwell

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 777 posts
  • Gender:Male
  • Location:Paris - France

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 14 June 2005 - 10:13 AM

For this prog you don't have to use any other subprogram than "TEXTCODE"... You just have to use some loops like For, While etc to replace your goto's by something more "robust" :)
Here is your prog without any goto:

While 1

1->E
1->X
1->Y
ClrText

Do
"Read which file"?->F
LpWhile F>6 Or F<0

F=1=>File1
F=2=>File2
F=3=>File3
F=4=>File4
F=5=>File5
F=6=>File6
ClrText

1->Z
While Z<49 And E><2
Prog "TEXTCODE"
X+1->X
If X=22 Or N=2
Then Y+1->Y
1->X
IfEnd
1->N
Z+1->Z
WhileEnd

While Getkey><31:WhileEnd

WhileEnd


#18 SRM

SRM

    Casio Addict

  • Members
  • PipPipPip
  • 77 posts
  • Location:France

  • Calculators:
    G 100

Posted 14 June 2005 - 03:32 PM

I totally agree with Orwell. However, for a faster prog, you should replace
Prog "TEXTCODE"
by
List 1[Z
Ans<26=>Prog "TEXTCOD1"
Ans<52 And Ans>25=>Prog "TEXTCOD2"
Ans<76 And Ans>51=>Prog "TEXTCOD3"
Ans>75=>Prog "TEXTCOD4"
Then in each sub-prog, you put a part of "TEXTCODE". This will make more sub-prog, I agree you, but this will divide by 4 the time of a cycle. It's not necessary to make a lot of subs or else, the effect would be reversed. In each "TEXTCOD", replace:
List 1[Z]=X=>
by
Ans=X=>


An other point of view is to make a picture you'll save. So it'll be very quick to draw. Then to make changes, you only have to place a cursor on the wrong letter and write in front of it, then you make a StoPict. However, be carefull with K,M,N,Q,W that take the place of 2 characters.

#19 dscoshpe

dscoshpe

    Casio Freak

  • [Legends]
  • PipPipPipPip
  • 185 posts
  • Location:California, USA

  • Calculators:
    AFX 2.0 (v1.00), 9850Ga+, 9800, BE-300 other..

Posted 16 June 2005 - 10:51 PM

Perhaps we should raise a challenge to see who can design a text writer with the lowest possible run time.

Perhaps standardize by requiring it write a pangram such as:
"The quick brown fox jumps over the lazy dog."
Something longer would be more telling of the text writer's power though...

Takers?

- dscoshpe -

#20 CrimsonCasio

CrimsonCasio

    UCF Ambassador

  • [Legends]
  • PipPipPipPipPipPipPipPipPipPip
  • 3579 posts
  • Gender:Male
  • Location:USA
  • Interests:Claculators, Stephen King, Video Games, Calculators, Programming, Calculators, Reading, Calculators... hmm, what else... Ah! Calculators!

  • Calculators:
    Algebra FX2.0, CFX 9850Ga+, Classpad 300

Posted 16 June 2005 - 11:19 PM

tempting...........

#21 tutti

tutti

    Casio Addict

  • Members
  • PipPipPip
  • 65 posts

  • Calculators:
    FX-9860G SD

Posted 18 June 2005 - 02:20 PM

SRM, I'll try that :)

#22 liquid

liquid

    Wannabe Casio God

  • Members
  • PipPipPip
  • 66 posts
  • Gender:Male
  • Location:NZ

  • Calculators:
    fx 9750 Plus

Posted 07 August 2005 - 09:50 AM

:plol: if u want a text editor that uses the whole screen, not like in program mode,,,,,then just write in ure text in run mode, and to save it to fuction memory, or load ure saved texts from fuction memory.

That gives u 6 text files , full screen, and fastest editing possible!

#23 tutti

tutti

    Casio Addict

  • Members
  • PipPipPip
  • 65 posts

  • Calculators:
    FX-9860G SD

Posted 09 August 2005 - 04:28 PM

I started making this program because I thought editors didn't exist already. But later, I've found editors that work much better than this would, so sorry, but I won't work on this anymore.

Thanks for your help, though.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users