Author Topic: String Parser  (Read 2407 times)

0 Members and 1 Guest are viewing this topic.

Demon

  • Guest
String Parser
« on: July 05, 2006, 05:05:00 pm »
I made a string parser that extracts the first part of a colon-delimited string.

c1-->
CODE
ec1"ITEM ONE:ITEM TWO:ITEM THREE:"
pgrmFPARSE
Disp Ans

ITEM ONE
c2
ec2

I'm using it for my graphical dialog, menu, and alert subroutines, along with some other program.
Is there any way I can make this go faster?

c1
-->
CODE
ec1Ans -> Str0
inString(Ans,":"+1 -> Y

Offline kalan_vod

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2715
  • Rating: +10/-0
    • View Profile
    • kalanrock.us
String Parser
« Reply #1 on: July 05, 2006, 05:38:00 pm »
Cool, I made something similar in Res.  

Offline tifreak

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2708
  • Rating: +82/-3
  • My Kung Fu IS strong...
    • View Profile
    • TI-Freakware
String Parser
« Reply #2 on: July 06, 2006, 01:31:00 am »
I will try to get you the routine I used for dialogue in my game...


QuoteBegin-"BASIC Code"+-->
QUOTE ("BASIC Code")
:4→Y
:1→C:2→W
:While W=2
:Text(X,Y,sub(Str0,C,1
:C+1→C:Y+4→Y
:If sub(Str0,C,1)="/
:Then
:C+1→C:X+6→X:4→Y:End
:If sub(Str0,C,1)="+
:Then
:Repeat getKey
:End
:For(Z,4,20
:Line(4,Z,90,Z,0
:End
:41→X:4→Y:C+1→C
:End
:If sub(Str0,C,1)="*
:1→W
:End
Generated by http://www.cemetech.net/projects/basicelite/sourcecoder.php,
Projects: AOD Series: 75% | FFME: 80% | Pokemon: 18% | RPGSK: 60% | Star Trek: 70% | Star Trek 83+: 40% | TI-City: 5%

Dragon__lance

  • Guest
String Parser
« Reply #3 on: July 06, 2006, 04:12:00 am »
tifreak8x's is a great routine for displaying text, i highly recommend it! Anyways,i think what pyro xp2k is trying to do is just a regular string parser/divider right? Well the only thing i see that can be quickened up is in the end,instead of the "0"->str0,just make it Delvar X,or some random variable.Then in the loop,make it While X,so right when x becomes 0,it exits the loop :)smile.gif

Demon

  • Guest
String Parser
« Reply #4 on: July 08, 2006, 08:25:00 am »
I changed it again.  I combined it with the other parser so now you can choose wheter you want to parse the whole thing and make an index or parse only the first item in the string (put a colon before the string).

You can put this right into TI-GRAPH LINK (chane the file location though below) and import it.
c1-->
CODE
ec1
\start83P\
\comment=Single file received by TiLP
\protected=FALSE
\name=ZPARSE
\file=D:\TISTUF~1\0PROGR~1\ZPARSE.TXT
If sub(Ans,length(Ans),1)\!=\":
Ans+":
Ans\->\Str0
If sub(Ans,1,1)=":
Then
sub(Ans,2,length(Ans)-1\->\Str0
0\->\W:Else:1\->\W
End
If W:Then
{1\->\L\2\:1\->\W:0\->\\theta\
While WinString(sub(Str0,W,length(Str0)-W+1),":
Ans+W\->\W
\theta\+1\->\\theta\
W-Ans\->\L\2\(1+dim(L\2\
End
While length(Str0)\!=\inString(Str0,":
inString(Str0,":
sub(Str0,1,Ans-1)+sub(Str0,Ans+1,length(Str0)-Ans\->\Str0
End
1+length(Str0\->\L\2\(1+dim(L\2\
Else
inString(Str0,":")+1\->\Y
If Ans(Anssub(Str0,1,Ans-2\->\Str9
sub(Str0,Y,length(Str0)-Y+1\->\Str0
Else
sub(Str0,1,length(Str0)-1\->\Str9
"0\->\Str0
End
End
\stop83P\
c2
ec2

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
String Parser
« Reply #5 on: July 08, 2006, 09:30:00 am »
sound cool, do you want me to move this in the calc project and idea section tho? as it was posted in the calc help^and support forums :Ptongue.gif

Demon

  • Guest
String Parser
« Reply #6 on: July 08, 2006, 09:37:00 am »
Sure.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
String Parser
« Reply #7 on: July 08, 2006, 12:51:00 pm »
there we go