This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. 68k Calculator Basic => TI-BASIC
Author Message
lafferjm


Member


Joined: 02 Aug 2006
Posts: 169

Posted: 27 Jan 2008 11:31:09 pm    Post subject:

Is there anyway to write a program filled with functions, then write another program that utilizes them. I have tried one way but i might be doing it wrong.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 27 Jan 2008 11:35:25 pm    Post subject:

If you want a program that uses lots of subfunctions, I suggest declaring the functions as local variables and then defining them using Define f(x,y)=Func. For example:

myprgm()
Prgm
Local f,g
Define f(x)=x^2
Define g(x)=Func
If x=0:Return true
Return x>5
EndFunc

Disp g(f(5))
EndPrgm


You can use subprograms in the same way.

The one drawback of this method is that I don't think the local functions/programs will be able to call each other. To get around this, you could declare them as global variables, then delete them when you're done. Be sure to be in a different folder when you declare global variables, though, rather than overwrite the user's variables.


Last edited by Guest on 30 Aug 2010 08:12:27 pm; edited 1 time in total
Back to top
lafferjm


Member


Joined: 02 Aug 2006
Posts: 169

Posted: 27 Jan 2008 11:42:37 pm    Post subject:

DarkerLine wrote:
myprgm()
Prgm
Local f,g
Define f(x)=x^2
Define g(x)=Func
If x=0:Return true
Return x>5
EndFunc

EndPrgm

[post="119595"]<{POST_SNAPBACK}>[/post]


Yeah but if i had that program and then created one that looked like

myprgm2()
Prgm
myprgm().f(x0
EndPrgm

i cant get it to work. How would i call the function in myprgm() from myprgm2()?


Last edited by Guest on 30 Aug 2010 08:12:12 pm; edited 1 time in total
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 27 Jan 2008 11:46:49 pm    Post subject:

Read the second part of my post. You'll need to declare f() as global. Then, just call it with f(x).
Back to top
lafferjm


Member


Joined: 02 Aug 2006
Posts: 169

Posted: 27 Jan 2008 11:47:56 pm    Post subject:

ahh okay thanks.
Back to top
Display posts from previous:   
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
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement