Hello! I have a little question. I've gotten a urge to make my own shell but I'm not getting anywhere. How can I save programs I found with the DetectVar( command so that I can list them sorted, for example? I don't program with Ice yet so long why I am not yet so experienced.
Where exactly are you having an issue? Using the DetectVar command to find vars, storing them somewhere, or sorting that list alphabetically?

If your problem is with storing the names gotten from DetectVar, you could try something like

Code:
0->INDEX
0->SEARCH
Repeat(not(SEARCH))
DetectVar(SEARCH,...)->Str2
If(SEARCH)
Copy(Str1+INDEX*9,Str2,9)
End
INDEX+9->INDEX
End
INDEX/9->SIZE

The number of files found will be stored in size, and the names of the programs can be found at Str2+0, Str2+9, Str2+18, etc.

Putting things in alphabetical order is a bit tougher. You'll have to make a string comparison function, or figure out how to call the OS's, or poke PT to implement it as a function. Basically, it just checks if the first letter of the first string is greater than that of the second. If so, it returns -1. If the first letter of the second string is greater, it returns 1. If the first letter of both strings are the same, it moves on to the next letter. If it reaches the end of the string, it returns 0.
Then, to actually do the sorting. There's a lot of explainations of different methods of sorting online. One way to do it might involve looking through each of the names (which can be found at 0, 9, 18, 27... In the above example), and finding the string that comes first in alphabetical order (where the string comparer is -1 or 0 when comparing to any other string), then switching that with the first element of the list. Then, move on to the next string until you reach the end.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement