Author |
Message |
|
Flameviper
Advanced Newbie
Joined: 05 Jun 2008 Posts: 62
|
Posted: 01 Aug 2008 01:03:18 pm Post subject: |
|
|
I was thinking of making a Notepad-style text editor. The only problem is everything.
Presumably it would include copy/cut/paste capacity, but with insertion or deletion you'd have to move every a character after the point of the operation (an INSERT feature would have the same problem). Or whether to encode the data as a list or string. Strings require no translation (a list would have A as 1, B as 2 etc. which would require a long-a decoder AND encoder), but there are only 9 strings whereas there are infinite amounts of lists. And then there's the problem of just about everything else.
I think I'm in over my head here, can someone give me some hints? Or has this been done before and I didn't realize it? |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 01 Aug 2008 01:15:36 pm Post subject: |
|
|
I suggest editing the data as a string, but then saving it to a list, giving you the best of both worlds. You'd have to encode or decode only once, when saving or loading a file.
You'd have to make sure to make optimal use of each element of the list to avoid wasting memory. |
|
Back to top |
|
|
Flameviper
Advanced Newbie
Joined: 05 Jun 2008 Posts: 62
|
Posted: 01 Aug 2008 02:19:23 pm Post subject: |
|
|
DarkerLine wrote: I suggest editing the data as a string, but then saving it to a list, giving you the best of both worlds. You'd have to encode or decode only once, when saving or loading a file.
You'd have to make sure to make optimal use of each element of the list to avoid wasting memory.
[post="125680"]<{POST_SNAPBACK}>[/post]
Well, encoding two numbers to an element means 676 possibilities. It would be possible to encode two numbers in one (like 23 for BC), which could be divided by 10 and the decimal part/integer part separated, but that wouldn't work because letters go to 26. Maybe having it go 10, 11, 12, 13 instead of 1, 2, 3, 4?
Plus I'm not very familiar with lists, the manual isn't helping me much either.
Last edited by Guest on 01 Aug 2008 02:19:52 pm; edited 1 time in total |
|
Back to top |
|
|
Flameviper
Advanced Newbie
Joined: 05 Jun 2008 Posts: 62
|
Posted: 01 Aug 2008 02:30:34 pm Post subject: |
|
|
Okay. Sorry for double-post but I thought this warranted one.
From what I can gather, this is what the program would look like (vaguely).
Menu of Text( commands, it would use getKey on the 5 buttons below the LCD to choose an option or maybe a cursor controlled by the arrow keys. This menu would select from 20 LISTS that could be used for storing stuff. The one at the bottom would be labeled NEW, and that subroutine would have a deliberate error in it allowing you to access it and create a new list name or modify old ones.
Now here's what I see as far as lists.
LNOTE01, if it's called that, would look something like { 1011, 1213 } for the sequence ABCD. To display the numbers, it would divide LNOTE01(X) by 10, turn the iPart into one number to be rendered, and turn the fPart into the next one.
My idea for this is to divide it into trees, like sending each number through a process like
Dim(LNOTE01)->Y
For (X, 1,Y,1)
(LNOTE01(X))-> Z
Z/10->Z
iPart(Z) -> W
If W = 10
Then
Text (y-coord,x-coord,"A"
End
And so on for all 26 letters. Please tell me there's a better way to do this. |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 01 Aug 2008 04:03:12 pm Post subject: |
|
|
Yes, there is: look up the sub( command. This is easy to use for converting a number to a character; the inString( command can be used to go the other way.
You'll want more than 26 possible symbols, and probably the possibility of changing which symbols are available easily. As long as you have 100 possible characters or less, you can fit 7 characters into a single real number easily: two digits to each character. (Using the exponent, you can do better and fit 8 characters in, but it means trickier code)
Also, it's possible to recall a list with an arbitrary name: expr("L"+Str0 will be evaluated to the list whose name is in Str0. Unfortunately, this can't be used for storing to lists.
Last edited by Guest on 30 Jul 2010 05:11:56 am; edited 1 time in total |
|
Back to top |
|
|
thebetter1
Advanced Newbie
Joined: 09 Jul 2008 Posts: 86
|
Posted: 03 Aug 2008 11:19:47 pm Post subject: |
|
|
You can actually put up to 5 letters in a list element. It is a bit more complicated, but it works:
{1011121314}=ABCDE
iPart(1011121314/100000000->A
1011121314-100000000A->B
iPart(B/1000000->B
1011121314-100000000A-1000000B->C
iPart(C/10000->C
1011121314-100000000A-1000000B-10000C->D
iPart(D/100->D
1011121314-100000000A-1000000B-10000C-100D->E
This causes A to equal 10, B to equal 11, and so on. The fact that the letters here are the same as their codes is actually a complete coincidence.
Last edited by Guest on 04 Aug 2008 12:05:58 pm; edited 1 time in total |
|
Back to top |
|
|
tifreak8x
Elite
Joined: 27 Aug 2005 Posts: 956
|
Posted: 03 Aug 2008 11:53:38 pm Post subject: |
|
|
Or, you can utilize Celtic 2 to take the data from the string and send it to a program or app var file. In that way, you are using minimal amounts of variables, and the data is stored safely away. |
|
Back to top |
|
|
WikiGuru ADOS (Attention deficit... Oh! Shiny!)
Elite
Joined: 15 Sep 2005 Posts: 923
|
Posted: 04 Aug 2008 12:45:46 am Post subject: |
|
|
That takes away from the fun ;)
you can get 8 letters into a real (as Darkerline suggested).
Here's the code from real to string. I'm pretty sure it works (actually tested it!)
:DelVar E" ->Str2
:"ABCDEFGHIJKLMNOPQRSTUVWXYZ ->Str1
:Repeat E>dim(L1
:E+1->E
:L1(E->A
:length(Str1->B
:While iPart(A10^(B
:B-1->B
:End
:A10^(B->A
:-B->B
:For(C,1,7
:Str2+sub(Str1,iPart(A10^(2)),1)->Str2
:fPart(A10^(2->A
:End
:Str2+sub(Str1,B-1,1->Str2
:End
:sub(Str2,2,length(Str2)-1->Str2
It's easy to change valid characters and their values by modifying Str1, and it has a maximum of 99 different characters.
edit2: converting back to real
:DelvarL10->dim(L1
:"ABCDEFGHIJKLMNOPQRSTUVWXYZ ->Str1
:DelvarE1->C
:While fPart(length(Str2)/8
:Str2+" ->Str2
:End
:length(Str2->D
:If D>7:7->D
:Repeat D+1>length(Str2
:DelVar A1+E->E
1+dim(L1->dim(L1
:For(B,C,D
:A+inString(Str1,sub(Str2,B,1))10^(-2B+2C-1->A
:End
:A10^(inString(Str1,sub(Str2,D+1,1->L1(E
:2+D->C
:8+D->D
:End
Note that this code will append extra spaces on the end of the Str2 if it's length is not a multiple of 8.
edit3: Changed to real->String code so it will take input from a list
edit4: wow, so many edits... I found problems with both codes. I can't seem to make a fix for them, but i'm sure someone here can (or just re-write them). It has to deal with the first character equate being larger than 9.
Last edited by Guest on 30 Jul 2010 05:13:05 am; edited 1 time in total |
|
Back to top |
|
|
WikiGuru ADOS (Attention deficit... Oh! Shiny!)
Elite
Joined: 15 Sep 2005 Posts: 923
|
Posted: 05 Aug 2008 03:24:26 pm Post subject: |
|
|
Sorry for double posting, but I've finally worked it out (both codes) and didn't want another edit...
String to Real:
:DelVar L10->dim(L1
:"°°°°°°°°°ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-*/.,(){}[] ->Str1
:DelVar E1->C
:While fPart(length(Str2)/8
Str2+" ->Str2
:End
:length(Str2->D
:If D>7:7->D
:Repeat D+1>length(Str2
:DelVar A1+E->E
:1+dim(L1->dim(L1
:For(B,C,D
:A+inString(Str1,sub(Str2,B,1))10^(2C-2B-1->A
:End
:A10^(inString(Str1,sub(Str2,D+1,1->L1(E
:2+D->C
:8+D->D
:End
Real to String:
:DelVar E" ->Str2
:"°°°°°°°°°ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-*/.,(){}[] ->Str1
:Repeat E>=dim(L1
:E+1->E
:DelVarBL1(E->A
:While iPart(A10^(-B
:B+1->B
:End
:A10^(-B->A
:For(C,1,7
:Str2+sub(Str1,iPart(A10^(2)),1)->Str2
:fPart(A10^(2->A
:End
:Str2+sub(Str1,B-1,1->Str2
:End
:sub(Str2,2,length(Str2)-1->Str2
The String to Real runs surprisingly fast, but Real to String is slow... oh well, have fun.
Last edited by Guest on 30 Jul 2010 05:11:06 am; edited 1 time in total |
|
Back to top |
|
|
|