Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: joao9856 on January 24, 2013, 09:43:31 am
-
Is it possible to call a program from inside another program?
-
It is in TI Basic
Under the prgm menu, go to the exec tab and directly enter the program you want to call on it's own line in the editor.
-
i can't find that. Also important info i'm using Ti-Nspire
-
Well than you can't find that indeed :P Homer gave instructions for the TI84 series (which is assumed if you say "TI BASIC"). For Nspire, you just call a program by typing its name. example:
Define example()=
Prgm
anotherprogram()
EndPrgm
-
i can't find that. Also important info i'm using Ti-Nspire
Whoops, my bad. I assumed the 83/84 due to the forum category :P
(Now that I think about it, do we have a separate forum for Nspire-Basic?)
ElementCoder gave the method for the Nspire. However, if I remember correctly subroutines called in a program must be defined elsewhere in the same document. I think there's a way to make it so you'll only need to define a program once and not everytime you use a new document, but it's been a while since I've done anything with the Nspire. <.<
-
i called a program in an if statement and it does not save the variables
define example()
requeststr"a b c",choose,0
if choose="b" then
bcode()
text"its b"
its something like that what i've created
-
Choose may be a local variable in the parent program, and thus bcode() doesn't know about it.
You could have choose as a global variable or pass in an argument to bcode()
define example()
requeststr"a b c",choose,0
if choose="b" then
bcode(choose)
text"its b"
Like so.
Edit: bcode() would look like
define bcode(choose)
-
got it i didn't need to change anything but thanks.
next time i should remember to save all programs. :crazy:
What happened was that i was building a program and saved it so i could see its working, but i forgot to save the "bcode program", so i was trying to runa program that was not there.
-
...I think there's a way to make it so you'll only need to define a program once and not everytime you use a new document...
There is, you'd have to make your program LibPriv or LibPub. LibPub will make it show up in the catalog, LibPriv means it won't. This can be set in the program editor by going to menu>1: Actions>7: Change Library Acces. You'd then access it by calling <libraryname>\function()
Yeah running a program that isn't there won't do much :P though that should have given you an error "Function not defined" (or you must mean you gave it no body).
-
probably only saved it while it was clean
-
I have just decided to pick up my "book-that-never-came-further-than-title-page" about Nspire BASIC, I should have a chapter or two done by the end of the week, though that probably won't be of help for you, Ch.1 will be about the editor and it's functionality and Ch.2 will be the hello world :)
-
I think i wont be learning much, but i never know specialy because i only code in ti-nspire with simple tasks, that is before my current project.(trying a menu only rpg with level system :hyper:)
-
If you want to make an RPG you should most definitely look at TI RPG and TI RPG 2 both by Superbany, especially the latter is extremely well made.
-
thanks for the help!
-
New question, is there anyway of puting a variable inside a requeststr like this:
request "I have x peanuts and you?",peanuts,0
Edit:another Question
How can i from a number like 9.57 turn into 9?
if you didn't understand please say it.
-
You have to use the string concatenation operator:
Text "I have "&string(x)&" peanuts"
If x is a string you can leave out the 'string()' command. If x is a non string value, you have to stringify it first using 'string(argument)'.
-
i edited last post(alot), and i don't think it works with request.
EDIT: Made it thanks
-
With request is the same way :) And for new questions you should just post again. That way we can see you have a new question, plus now it looks like my answer comes out of nowhere. Don't use edit to delete you entire previous question, just ask again :)
-
With request is the same way :) And for new questions you should just post again. That way we can see you have a new question, plus now it looks like my answer comes out of nowhere. Don't use edit to delete you entire previous question, just ask again :)
oooookkkkkk