Author Topic: Sort by alphabetical order  (Read 11774 times)

0 Members and 1 Guest are viewing this topic.

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Sort by alphabetical order
« 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 ?
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline jacobly

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 205
  • Rating: +161/-1
    • View Profile
Re: Sort by alphabetical order
« Reply #1 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
« Last Edit: March 05, 2013, 01:30:29 pm by jacobly »

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Sort by alphabetical order
« Reply #2 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 ???
« Last Edit: March 06, 2013, 11:44:47 am by Hayleia »
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Turtle

  • Not an admin
  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 10
  • Rating: +0/-0
    • View Profile
Re: Sort by alphabetical order
« Reply #3 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.
« Last Edit: October 06, 2013, 01:09:27 am by admin000 »

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Sort by alphabetical order
« Reply #4 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)
« Last Edit: October 06, 2013, 03:14:23 am by Hayleia »
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Turtle

  • Not an admin
  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 10
  • Rating: +0/-0
    • View Profile
Re: Sort by alphabetical order
« Reply #5 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...

Offline ClrDraw

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 627
  • Rating: +61/-2
    • View Profile
    • GitHub
Re: Sort by alphabetical order
« Reply #6 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.
« Last Edit: November 27, 2013, 12:17:17 pm by ClrDraw »
Visit my GitHub for all my TI programs as well as other projects.
Also check out my website.

Offline LDStudios

  • Coder Of Tomorrow
  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 388
  • Rating: +41/-1
    • View Profile
    • LD Studios
Re: Sort by alphabetical order
« Reply #7 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



Offline ClrDraw

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 627
  • Rating: +61/-2
    • View Profile
    • GitHub
Re: Sort by alphabetical order
« Reply #8 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.
Visit my GitHub for all my TI programs as well as other projects.
Also check out my website.

Offline ClrDraw

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 627
  • Rating: +61/-2
    • View Profile
    • GitHub
Re: Sort by alphabetical order
« Reply #9 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!
« Last Edit: November 27, 2013, 12:16:42 pm by ClrDraw »
Visit my GitHub for all my TI programs as well as other projects.
Also check out my website.

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: Sort by alphabetical order
« Reply #10 on: October 19, 2013, 01:44:25 pm »
ClrDraw: You should edit posts instead of double-posting ;)



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline ClrDraw

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 627
  • Rating: +61/-2
    • View Profile
    • GitHub
Re: Sort by alphabetical order
« Reply #11 on: October 19, 2013, 01:46:43 pm »
Sorry, new user.
Visit my GitHub for all my TI programs as well as other projects.
Also check out my website.

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Sort by alphabetical order
« Reply #12 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 :)

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

« Last Edit: October 19, 2013, 01:53:39 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: Sort by alphabetical order
« Reply #13 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! :)



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

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
Re: Sort by alphabetical order
« Reply #14 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).
« Last Edit: October 19, 2013, 05:31:12 pm by DJ Omnimaga »