Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Demon on July 05, 2006, 05:05:00 pm

Title: String Parser
Post by: Demon 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
Title: String Parser
Post by: kalan_vod on July 05, 2006, 05:38:00 pm
Cool, I made something similar in Res.  
Title: String Parser
Post by: tifreak 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,
Title: String Parser
Post by: Dragon__lance 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
Title: String Parser
Post by: Demon 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
Title: String Parser
Post by: DJ Omnimaga 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
Title: String Parser
Post by: Demon on July 08, 2006, 09:37:00 am
Sure.
Title: String Parser
Post by: DJ Omnimaga on July 08, 2006, 12:51:00 pm
there we go