Author Topic: Read lowercase letters from Ti-Basic string  (Read 4497 times)

0 Members and 1 Guest are viewing this topic.

Offline Giacomo Pigani

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 12
  • Rating: +0/-0
    • View Profile
Read lowercase letters from Ti-Basic string
« on: December 03, 2015, 04:47:49 am »
Let's say that in a normal Ti-Basic program i create a string like this:

Code: [Select]
"Lorem ipsum dolor"->Str1
And then I have and Axe program I made to display text.

To display I do something like this (oversimplified example)
I like it this way so I can do some checks on A, reduce pixels from one letter to another and so on...

Code: [Select]
{S+C}→A
while A≠0
Text(J,I,°A)
{S+C}→A
End

If I take the variable like this, only uppercase letter work (I think it has something to with 1 byte and 2 bytes tokens)
Code: [Select]
"Str1"→Str1
GetCalc(Str1)→S

However, directly assigning a string in Axe works (I read somewhere that all letters use 1 byte in axe)
Code: [Select]
"Lorem ipsum dolor"->S

I found this question which seems linked to my problem, but I'm not entirely sure and it also got no answers.
Here Runer112, says "TI Program Editor parses these as these special tokens and not lowercase letters. Due to this, they turn into garbage when parsed inside strings by Axe".
https://www.omnimaga.org/the-axe-parser-project/features-wishlist/msg132719/?topicseen#msg132719



Maybe I'll take a look at TokenIde to see if something can be done. Otherwise I though the Copy function could have been of help. Do you know any solutions?

Offline c4ooo

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 252
  • Rating: +10/-1
  • The impossible chemical compound.
    • View Profile
Re: Read lowercase letters from Ti-Basic string
« Reply #1 on: December 03, 2015, 08:37:03 am »
It is bit hard to understand what you are trying to say, but i will try to help you.
When you do "Mare Nostrum"->Str1, it stores the lowercase letters as two byte tokens.
Axe, on the other hand, stores the strings directly as a bunch of one-byte chars, so that instead of being a token, a lowercase letter is just a [one byte] char. So in axe "Test" will be converted to "54(char-T) 65(char-e) 73(char-s) 74(char-t) 00"; but in tibasic "Test" will be stored as "54(char-T) XX XX(token-e) XX XX(token-s) XX XX(token-t) 00". ("XX" means i dont know that particular byte. Inside the "()" is the value of the hex number. The "00" is the terminating char, telling the text routines to stop printing the text)
If you render the string as a set of tokens, however, it will render correctly.

I cant formulate my thought too well, but i hope you understand.
-German Kuznetsov
The impossible chemical compound.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Read lowercase letters from Ti-Basic string
« Reply #2 on: December 04, 2015, 02:29:38 pm »
The TI-OS strings uses tokens, not ASCII. Meanwhile, Axe strings use ASCII. The lowercase tokens are 2-byte tokens starting with $BB, and the second byte starts with 'a' = $B0, but $BB is skipped. In ASCII, 'a'=61h. Putting this confusing mess together, we need to convert $BBB0 -> $61, and so on. I think the following code will work, but only for uppercase and lowercase letters:
Code: [Select]
;;Assume S points to the OS String data, C is the size of the string

0→I→J
While C
{S}→A
If A=187
{S+1→S}-$4F→A
If A>106
A-1→A
End
End
Text(J,I,°A)
I+1 and 16→I
If I=0
J+1 and 8→J
End
S+1→S
C-1→C
End

Offline Giacomo Pigani

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 12
  • Rating: +0/-0
    • View Profile
Re: Read lowercase letters from Ti-Basic string
« Reply #3 on: February 13, 2016, 07:28:17 pm »
Thank for pointing me in the right direction. I came up with a Lbl. It' isn't over yet, but it includes almost all the characters used

Code: [Select]
Lbl ASCII
    A→D
    If A=4:28→D:End
    If A=6:193→D:End
    If A=7:93→D:End
    If A=8:123→D:End
    If A=9:125→D:End
    If A=11:20→D:End
    If A=16:40→D:End
    If A=17:41→D:End
    If A=41:32→D:End
    If A=42:34→D:End
    If A=43:44→D:End
    If A=44:215→D:End
    If A=45:33→D:End
    If A=58:46→D:End
    If A=62:58→D:End
    If A=106:61→D:End
    If A=107:60→D:End
    If A=108:62→D:End
    If A=109:23→D:End
    If A=110:25→D:End
    If A=111:24→D:End
    If A=112:43→D:End
    If A=113:45→D:End
    If A=130:42→D:End
    If A=131:47→D:End
    If A=174:39→D:End
    If A=175:63→D:End
    If A=176:26→D:End
    If A=240:94→D:End
   
    If A=187
        C++
        1→Z
       
        If {S+C}≥159 ? {S+C}≤164
            {S+C}+28→D
        End
       
        If {S+C}=165:194→D:End
        // Where is Mu? (166)
        If {S+C}=167:195→D:End
        If {S+C}=168:196→D:End
        If {S+C}=169:197→D:End
        If {S+C}=171:201→D:End
        If {S+C}=172:202→D:End
       
        If {S+C}≥176 ? {S+C}≤186
            {S+C}-79→D
        End
       
        If {S+C}≥188 ? {S+C}≤202
            {S+C}-80→D
        End
       
        If {S+C}=203:199→D:End
        If {S+C}=204:200→D:End
        If {S+C}=207:126→D:End
        If {S+C}=209:64→D:End
        If {S+C}=210:35→D:End
        If {S+C}=211:242→D:End
        If {S+C}=212:38→D:End
        If {S+C}=213:96→D:End
        If {S+C}=214:59→D:End
        If {S+C}=215:92→D:End
        If {S+C}=216:124→D:End
        If {S+C}=217:95→D:End
        If {S+C}=218:37→D:End
        If {S+C}=219:206→D:End
        If {S+C}=241:8→D:End
    End
   
   
    //Special unused codes, used by me
    If A=38:6→D:End
   
   
    D→A
Return

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Read lowercase letters from Ti-Basic string
« Reply #4 on: February 13, 2016, 11:16:28 pm »
I think the following will work, though I can't test at the moment.

If S points to the BASIC string, L is the length, then the following code will return the token string in ASCII at E848E and the size of the ascii string in C. As well, it will update S and L to pint to the next token.

Code: [Select]
Lbl TKSTR
Return!If L
L:Asm(444D78B1C8)
S:Asm(7EEFA342545D230B2002230B)->S
Asm(6069)->L
Asm(EBEF94456069)->C
Return