Author Topic: Help parsing a string  (Read 11851 times)

0 Members and 2 Guests are viewing this topic.

Offline Broseph Radson

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 295
  • Rating: +20/-1
  • Its 0x1A4 somewhere
    • View Profile
Re: Help parsing a string
« Reply #30 on: January 21, 2011, 05:40:14 pm »
Oh cool how?? Axe is amazing

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Help parsing a string
« Reply #31 on: January 21, 2011, 05:53:21 pm »
Er, let me dig up my source.

Okay, here's some example code. I'd post the original code, but it's very complex because I'm dealing with a lot of commands (and I also have a few 1500 byte strings laying around). Str1 is the key lookup table and defines all of the alphabet as well as the space button and the "." button. L2 holds the character set, although only not all of the keys defined in the lookup table have characters defined.

Code: [Select]
:.Lookup table
:[2F271F2E261E160E2D251D150D2C241C140C2B231B130B2A221A211911]→Str1
:.SET UP character TABLE
:For(A,65,90
:.SET LETTERS
:A→{L2+A-65}
:End
:.SET SPACE
:41→{L2+26}
:1→N→P+40→X→Y
:15→J+2→I
:.RECORD KEYPRESS
:getKey→K
:.REPLACE GRAPHICS ERASED BY    MOUSE
:sub(RCL
:If K>0
:.SEARCH LOOKUP TABLE
:!If K-56
:If P-1
:sub(BCK
:End
:Goto 01
:Else
:inString(K,Str1)→A
:End
:.IF KEYPRESS ISVALID
:If A
:If I+48<N
:1→N
:O+6→O
:End
:Text(I+N,J+O,L2+A-1►Tok
:{L2+A-1}→{L5+P}
:.MOVE CURSOR
:N+5→N
:P+1→P
:End
:End

The parser itself is kind of a mess though and over a thousand bytes of code. I'll let you figure it out :P
Hint: You just step through the string starting from L5.

There are also a lot of optimizations I haven't made yet, so...
« Last Edit: January 21, 2011, 05:54:07 pm by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline Broseph Radson

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 295
  • Rating: +20/-1
  • Its 0x1A4 somewhere
    • View Profile
Re: Help parsing a string
« Reply #32 on: January 21, 2011, 05:58:46 pm »
Looks cool ill try it out soooooooooon :)