Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Hayleia on March 05, 2013, 07:49:57 am

Title: Sort by alphabetical order
Post by: Hayleia on March 05, 2013, 07:49:57 am
Well, everything is in the title.
Say that I have a sequel of strings, all of them with a length of 8, all of them null terminated (the zero not included in the 8 characters), the start of the string being at P.
How to sort the strings by alphabetical order ?
Title: Re: Sort by alphabetical order
Post by: jacobly on March 05, 2013, 09:34:23 am
#Axiom(AMEMKIT)Alphabetical Memory Kit
First(TYPE)Key: XminFinds the first variable alphabetically of type TYPE, returns 0 if none.
Last(TYPE)Key: XmaxFinds the last variable alphabetically of type TYPE, returns 0 if none.
Next()Key: XsclFinds the next variable alphabetically of the same type, returns 0 if none.
Prev()Key: YminFinds the previous variable alphabetically of the same type, returns 0 if none.
dim()Returns the type of the current variable.
dim()rReturns a pointer to the data of the current variable.
dim()rrReturns the page of the current variable.
Print(BUF)Key: YmaxCopies the current variable's name to a buffer.
Print(BUF)rKey: YmaxCopies the current variable's type and name to a buffer.

Hint: If you want to search for programs, you can use 'prgm' for TYPE (use whatever dim() would return).
Hint: You can intermix calls to Next and Prev.
Warning Untested
Title: Re: Sort by alphabetical order
Post by: Hayleia on March 05, 2013, 09:58:04 am
Thanks :)
(and yeah, I can finally give you a +1 :P)

However, it would be great if you could add to the description which TI-OS tokens correspond to the Axiom tokens (I use TokenIDE so I will probably write ugly things such as ZXscl instead of First :P)
edit the previous post was edited to fit that request, thanks :)


edit I guess type 5 and 6 are different ? (that sounds like a stupid question).
edit In fact, 5 seems to look for all programs, protected or not, while 6 looks for only protected ones.
Also, Print(BUF)r seems not to work dafuq, it works now, without anything changed ???
Title: Re: Sort by alphabetical order
Post by: Turtle on October 05, 2013, 07:46:36 pm
That's great; can it be used to alphabetize the VAT? Also, do you have a short example program? Mine doesn't work:

Code: [Select]
.Shell
#Axiom(AMEMKIT)
Disp(First(5),i,Next(),i,Next())

Shouldn't this code display the first five programs in alphabetical order? It didn't work on my calc and gave me something weird.
Title: Re: Sort by alphabetical order
Post by: Hayleia on October 06, 2013, 03:13:21 am
This should not display the first five programs, but if it did what you thought, it would display the first three ones.
You are kind of saying this:
Disp TheFirst_Program, GotoNewLine, Disp TheNextOne, GotoNewLine, Disp TheNextOne.
And even so, that doesn't work because Next doesn't return a pointer to a string. You have to use Print.
Try doing something like that:

First(5)
."catch" the first program
Print(L3)
.copy its name to L3
Disp L3,i
.display the name and go to new line
Next()
."catch" the next program
Print(L3)
.you know what this is
Disp L3,i
.same
Next()
Print(L3)
Disp L3,i

(completely unoptimized)
Title: Re: Sort by alphabetical order
Post by: Turtle on October 06, 2013, 12:18:34 pm
Thank you, that did it. I'm not sure if I can use this though, it looks to me like it can only show what the main program menu shows : :-\ all my hidden programs don't show. I could make my program unhide everything, sort them, then hide all the ones that were originally hidden when it exits, but that would be complicated and time consuming...
Title: Re: Sort by alphabetical order
Post by: ClrDraw on October 19, 2013, 12:52:26 pm
I made a program called SRCSORT that easily sorts all programs in alphabetical order, hidden or not, but I cannot upload it yet because I don't have enough posts  :-\ once I have enough I'll put a link here.
Title: Re: Sort by alphabetical order
Post by: LDStudios on October 19, 2013, 12:56:58 pm
I made a program called SRCSORT that easily sorts all programs by alphabetical order, hidden or not, but I cannot upload it yet because I don't have enough posts  :-\ once I have enough I'll put a link here.
You can upload your file here www.ticalc.org, and put a link on this website
Title: Re: Sort by alphabetical order
Post by: ClrDraw on October 19, 2013, 01:23:48 pm
Okay thanks, I did that. It says it's pending and could take a few days though.
Title: Re: Sort by alphabetical order
Post by: ClrDraw on October 19, 2013, 01:40:53 pm
Never mind, I don't have 40 posts but for some reason it lets me upload now. Here it is!
Title: Re: Sort by alphabetical order
Post by: flyingfisch on October 19, 2013, 01:44:25 pm
ClrDraw: You should edit posts instead of double-posting ;)
Title: Re: Sort by alphabetical order
Post by: ClrDraw on October 19, 2013, 01:46:43 pm
Sorry, new user.
Title: Re: Sort by alphabetical order
Post by: Darl181 on October 19, 2013, 01:52:29 pm
Sorry, new user.
No worries, just make sure it doesn't become a habit ;) We all learn at some point.
Also if you plan on sticking around, feel free to introduce yourself (http://www.omnimaga.org/index.php?board=10.0) :)

E: also yeah I think you only need 5 or 10 posts to attach.

Title: Re: Sort by alphabetical order
Post by: flyingfisch on October 19, 2013, 02:27:48 pm
Sorry, new user.

No problem, you should have seen the 30+ necro/double posts I made on UCF when I first joined. ;)

Welcome to omnimaga! :)
Title: Re: Sort by alphabetical order
Post by: DJ Omnimaga on October 19, 2013, 05:28:35 pm
Never mind, I don't have 40 posts but for some reason it lets me upload now. Here it is!
I think the minimum is 5 posts for uploads, 1 post for editing your profile and 20 to use OmnomIRC (I think).

EDIT Actually it's 40 posts to upload in the downloads section, where a moderator will eventually approve your file (although above 1000 posts it's automatically approved instantly).