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
rrossorr


Newbie


Joined: 16 Mar 2007
Posts: 1

Posted: 16 Mar 2007 02:18:21 pm    Post subject:

hi,

I've been getting into programming my TI-89 to help ease my engineering calculations.

I have a couple questions:

(1). How do you make a function that has an optional parameter? For example, when you use to differentiate function, your parameters are: expression,variable[,order]

and you can either enter d(x^2,x) and it will give you the first derivative, or you can enter d(x^2,x,2) and it will give you the 2nd derivative.

(2). How can I make a custom hotkey? As an engineer there is a certain mathmatical calculations I have to make a LOT, and it would be so much easier if there was just a single key to achieve it (kind of like my own custom multiply sign or division sign). Is this possible?
Back to top
IAmACalculator
In a state of quasi-hiatus


Know-It-All


Joined: 21 Oct 2005
Posts: 1571

Posted: 16 Mar 2007 03:52:33 pm    Post subject:

The best (and maybe only) way to do optional parameters is to make your arguments into a list, and check the length. In this example, [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]z is a list with two mandatory parameter and one optional parameter.

[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]bleh(z)
Prgm
If dim(z)=3 then
Return (z[1]+z[2])*z[3]
Else
Return z[1]+z[2]
EndIf
EndPrgm

This program would add the first and second parameters, and would multiply it by the third, should you choose to input one.

As for the second question, you could assign your function to a kbdprgm. A kbdprgm is a program in your main folder that runs when you push [DIAMOND] and [1]-[6]. kbdprgm1 would run when you pressed [DIAMOND]+[1], kbdprgm2 would run when you did [DIAMOND]+[2], etc. You'd just make your function prompt on startup, like so:

[font="courier new;font-size:9pt;line-height:100%;color:darkblue"]quad()
Local a,b,c
Prgm
ClrIO
Input "A:",a
Input "B:",b
Input "C:",c
Pause (-b+{-1,1}√(b^2-4a*c))/(2a)
ClrIO
EndPrgm

That's for a simple quadratic program. I'm sure you can figure out how to adapt it to your needs.

Last edited by Guest on 16 Mar 2007 03:54:04 pm; edited 1 time in total
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