What is the basic code for detecting programs? All of my attempts to replicate the code have ended in failure. I am looking to make a new shell.
See https://www.cemetech.net/learn/ICE:Tips_and_Tricks , section 3. It's also supposed to be in the documentation, but not sure if that's added yet.
Because you didn't specify, I'm going to assume the language you would want something in is ICE.
Two of the ways I would go about detecting a program are using ti_DetectVar and ti_OpenVar.

If you use ti_OpenVar with a specified name, and tell it to open it in a mode that requires the appvar to already exist, such as "r",you can see if that program (or var) exists.

Code:

sum(0
sum(2, "SOMETHIN", "r", 5) -> A
If A
:code if program exists
Else
:code if program doesn't exist.
End

Make sure you use ti_Close() on that program after doing whatever you need to with it.
sum(2 is ti_OpenVar, and it's arguments are:
"SOMETHIN" the name of a program (you can also give it a pointer to a string)
"r" is the mode to open it in. In this case, you'd want to use read only mode because it returns a 0 if the program doesn't exist (or if something else goes wrong)
5 is the type of variable. 5 is for programs, and 6 is for locked programs (programs that you can't edit)

But if you want to create a list of programs, you can do something with ti_DetectVar:

Code:

0 -> A
Repeat not(B
sum(20, °A, 0, 5) -> B
If B
:do stuff here to save the found program
End
End

sum(20 is ti_DetectVar and the parameters are:
A is the search position. You want to reset this to 0 before starting the search, because this tells it from where to search from. The value of A is automatically changed when it searches.
0 is the data that the variable needs to start with. Because you're just searching for all programs, you set this to 0.
5 is the variable type (see above)

sum(20 returns a pointer to a string containing the name of the found program, remember that this pointer is usually always going to be the same, meaning that you need to do something with the string pointer right after using sum(20, before using it again.
  
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