Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: Demon on January 28, 2007, 02:58:00 pm

Title: String Array Subroutine
Post by: Demon on January 28, 2007, 02:58:00 pm
Well I finished the new string array sub... but I not sure how well I did as far as optimizing it....
Is there any thing I can do to make it any smaller or faster?

(‾ == negative)

Syntax:
"[][sin‾1([sin‾1(]]":prgmSA

:
1: Get value of an element from arrayy
2: Find string in array
3: Replace an element in array with string
4: Add an element to the array
5: Delete an element from the array

Example:
"1:000HI:HELLO:TEST:WAZZUP!
Returns: "HELLO"

"2:HI:HELLO:TEST:WAZZUP!sin‾1(TESTsin‾1(3
Returns: 2

"3:001HI:HELLO:TEST:WAZZUP!sin-1(WAT IT DO?sin‾1(3
Returns: "HI:WHAT IT DO?:TEST:WAZZUP!"

"4:002HI:HELLO:TEST:WAZZUP!sin-1(WAT IT DO?sin‾1(3
Returns: "HI:HELLO:WHAT IT DO?:TEST:WAZZUP!"

"4:003HI:HELLO:TEST:WAZZUP!
Returns: "HI:HELLO:WAZZUP!"

QuoteBegin-"BASIC Code"+-->
QUOTE ("BASIC Code")
:DelVar XAns→Str7
:expr(sub(Ans,1,1→Z
:sub(Str7,2,1→Str6
:sub(Str7,3,length(Str7)-2→Str7
:1+inString(Ans,"sin‾1(
:If Ans>1:Then
:sub(Str7,Ans,length(Str7)-Ans+1→Str5
:length(Ans→K
:1+inString(Str5,"sin-1(
:If Ans>1:Then
:1+expr(sub(Str5,Ans,length(Str5)-Ans+1→V
:sub(Str5,1,‾1+inString(Str5,"sin‾1(→Str5
:Else
:‾1→X
:End
:sub(Str7,1,length(Str7)-1-K→Str7
:Else
:"sin‾1(→Str5
:End
:If X<0:Return
:If Z=2:Goto 2
:expr(sub(Str7,1,3→Y
:sub(Str7,4,length(Str7)-3)+Str6→Str7
:DelVar W1→P/Y
:For(X,1,Y
:1+W→W
:min(length(Str7)-1,1+inString(Str7,Str6,P/Y→P/Y
:End
:If Z=1:Goto 1
:length(sub(Str7,Ans,inString(Str7,Str6,Ans)-Ans→X
:If Z=3:Goto 3
:If Z=4:Goto 4
:If Z=5:Goto 5
:Lbl 1
:sub(Str7,Ans,inString(Str7,Str6,Ans)-Ans→Str7
:Return
:Lbl 2
:inString(Str7,Str5→X
:If Ans:Then
:1→P/Y:0→PMT
:While P/Y≠X
:1+inString(Str7,Str6,P/Y→P/Y
:1+PMT→PMT
:End
:Else:‾1:End
:Return
:Lbl 3
:"
Title: String Array Subroutine
Post by: DJ Omnimaga on January 29, 2007, 02:59:00 am
mhmm interesting, do you have a 8xp version so i could mess around with it? And what would be the best use for me for this? I mean could this be adapted for a RPG in a text speech routine?
Title: String Array Subroutine
Post by: Demon on January 29, 2007, 12:55:00 pm
I'm using it in PyroEdit, and am going to use it in  the Adaelus IDE, and for Nakamuru III.

It could even use this to make multilingual programs, but it might need to be sped up a little before that... maybe if I write it in ASM (yeah, like that's ever gonna happen...)

I'll have the 8xp version later 'cause I gotta work on it a little bit more and get rid of those "one-element" errors.
Title: String Array Subroutine
Post by: DJ Omnimaga on January 30, 2007, 03:11:00 am
I see now. What is Adaelus IDE? o.oblink.gif I must have missed something. You have lot of projects you know :Dbiggrin.gif
Title: String Array Subroutine
Post by: Halifax on January 30, 2007, 10:59:00 am
I need to get back into basic

ASM  :rocket:rocket.gif

ASM  :chaingun:mitraillette.gif


Rock on

:rockband:rockband.gif
:woship:s024.gif:woship:s024.gif:woship:s024.gif:woship:s024.gif:woship:s024.gif:woship:s024.gif:woship:s024.gif
:woship:s024.gif:woship:s024.gif:woship:s024.gif:woship:s024.gif:woship:s024.gif:woship:s024.gif:woship:s024.gif
Title: String Array Subroutine
Post by: trevmeister66 on January 30, 2007, 11:34:00 am
I need to get INTO asm.

Laziness  :chaingun:mitraillette.gif

mmm... maybe some oter day <_<dry.gif
Title: String Array Subroutine
Post by: DJ Omnimaga on January 31, 2007, 03:21:00 am
that was so... random. Both languages are great, try to not learn both at once tho :Ptongue.gif
Title: String Array Subroutine
Post by: trevmeister66 on January 31, 2007, 11:08:00 am
actually yesterday i learned a bit about asm!!! just the basics though, but i'm progressing :)smile.gif
Title: String Array Subroutine
Post by: DJ Omnimaga on February 01, 2007, 03:26:00 am
good to hear

and yeah i saw the grayscale low res porn movie you posted in the irc channel yesterday, that was a quite huge set of 8xp files o.oblink.gif (666 KB)

j/k
Title: String Array Subroutine
Post by: Demon on February 01, 2007, 02:47:00 pm
Well I finished it and now it no longer uses L2 or Str5-6.
Now you can have all sorts of arrays and even multi-dimensional arrays with less trouble.

It'll get released with PyroEdit III.
Title: String Array Subroutine
Post by: Jon on February 01, 2007, 04:40:00 pm
QUOTE
I need to get back into basic


What's with all the asm-hatin'?
Title: String Array Subroutine
Post by: DJ Omnimaga on February 02, 2007, 01:51:00 am
lol don't worry I doubt he hate asm, he prbly doesn't like how tedious/hard it is to program something in it and like how easy he can make something in BASIC. Of course there's nothing wrong using basic either tho, especially considering what some ppl can do *cough*tifreak8x, bryan thomas, Hitoshi Koizumi (sp?), zeromus*cough*
Title: String Array Subroutine
Post by: Halifax on February 02, 2007, 09:27:00 am
Hatin?? First off note that I joke a lot. Second of I was just saying I need to get back into basic because I have lost touch like cause I long time before I started ASM I would have been able to help with this. Xlibman is right no problem with either language.
Title: String Array Subroutine
Post by: Demon on February 06, 2007, 03:14:00 pm
I got a string array subroutine I made in BASIC. It lets you mess with lists except the elements are strings (like this: {"ELEMENT 1","ELEMENT 2","APPLE","ORANGE","BANANAS"} ) rather than numbers since the guys at TI didn't think people would need to be doing that for any reason... and now want to make in ASM because it is really slow in BASIC.

How would I go about making something like this in ASM?
(Yeah, I know I shouldn't be rushing so fast into ASM's deep waters when I already have trouble swimming on the shallow end, but I need this subroutine for some programs I'm making in BASIC).

Any suggestings?
Title: String Array Subroutine
Post by: Demon on February 06, 2007, 05:51:00 pm
Here's the updated source code for the version I have right now.

1: Get value of an element from array
2: Find string in array
3: Replace an element in array with string
4: Add an element to the array, increment theta
5: Delete an element from the array, decrement theta.
6: Count the number of elements in the array and put it into theta.

c1-->
CODE
ec1:DelVar XAns→Str7
:expr(sub(Ans,1,1→Z;Get the function. 1-Get, 2-Find, 3-Replace, 4-Add, 5-Delete, 6-Count
:sub(Str7,2,1→Str6
:sub(Str7,3,length(Str7)-2→Str7
:If Z=6:Goto 6
:1+inString(Ans,"sin-1
:If Ans>1:Then
:sub(Str7,Ans,length(Str7)-Ans+1→Str5
:length(Ans→K
:1+inString(Str5,"sin-1
:If Ans>1:Then
:1+expr(sub(Str5,Ans,length(Str5)-Ans+1→θ
:sub(Str5,1,‾1+inString(Str5,"sin-1→Str5
:End
:sub(Str7,1,length(Str7)-1-K→Str7
:Else
:"sin-1→Str5
:End
:If Z=2:Goto 2
:expr(sub(Str7,1,3→Y
:sub(Str7,4,length(Str7)-3)+Str6→Str7
:DelVar W1→P/Y
:For(X,1,Y
:1+W→W
:min(length(Str7)-1,1+inString(Str7,Str6,P/Y→P/Y
:End
:If Z=1:Goto 1
:length(sub(Str7,Ans,inString(Str7,Str6,Ans)-Ans→X
:If Z=3:Goto 3
:If Z=4:Goto 4
:If Z=5:Goto 5
:Lbl 1
:sub(Str7,Ans,inString(Str7,Str6,Ans)-Ans→Str7
:Goto X
:Lbl 2
:inString(Str7,Str5→X
:If Ans:Then
:1→P/Y:0→PMT
:Repeat Ans=1
:1+PMT→PMT
:1+inString(Str7,Str6,P/Y→P/Y
:inString(sub(Str7,Ans,length(Str7)-Ans+1),Str5
:End
:PMT
:Else
:‾1
:End
:Goto X
:Lbl 3
:If θ>1:Then
:"
:If P/Y>1
:Ans+sub(Str7,1,P/Y-1
:Ans+Str5
:If W<θ
:Ans+sub(Str7,P/Y+X,length(Str7)-X-P/Y
:sub(Ans,2,length(Ans)-1→Str7
:Else
:Str5→Str7
:End
:Goto X
:Lbl 4
:If W<1:Then
:Str5+Str6+Str7→Str7
:Else
:"
:Ans+sub(Str7,1,(P/Y-1)(W<θ)+(W≥θ)length(Str7
:Ans+Str5+Str6
:If W<θ
:Ans+sub(Str7,P/Y,length(Str7)-P/Y
:sub(Ans,2,length(Ans)-1→Str7
:End
:θ+1→θ
:Str7
:Goto X
:Lbl 5
:"
:If θ>1:Then
:If P/Y>1
:Ans+sub(Str7,1,P/Y-2
:If W+1<θ
:Ans+sub(Str7,P/Y+X+(P/Y≤1),length(Str7)-P/Y-X-(P/Y≤1
:sub(Ans,2,length(Ans)-1→Str7
:θ-1→θ
:Else
:" →Str7
:End
:Str7
:Goto X
:Lbl 6
:1→P/Y:‾1→PMT
:Repeat Ans=1
:1+PMT→PMT
:1+inString(Str7,Str6,P/Y→P/Y
:End
:PMT→θ
:Lbl X
:DelVar DelVar DelVar Zc2
ec2