Ti BASIC User defined fucntion use in a program

  • Calculators
  • Thread starter Saladsamurai
  • Start date
  • Tags
    Program
In summary, the conversation discusses the difficulties the speaker is having with using Ti BASIC and user defined functions. They mention that in other languages, calling a user defined function within a program is simple, but in Ti BASIC it seems to be failing. The speaker provides an example of a user defined function and a program using it, and wonders why it is not working. They also mention using Ti GraphLink to send the code to their calculator. The conversation ends with a request for thoughts or ideas on the issue.
  • #1
Saladsamurai
3,020
7
I am trying to figure out why Ti BASIC is the worst language ever. Every other language, if you want to use a user defined function within a user defined program, you simply write the function above (or below) the sub routine and then you can call it to your hearts delight...why is Ti BASIC failing me here? (I am using Ti89 Titanium.)


All I want to do is a simple test here. Here is a user defined function that simply take an argument and then returns that argument (and this works if I type it directly into my calculator)

Code:
Func
newdisp(stuff)
Return Stuff
EndFunc

Now I want to do a simple test program that calls newdisp and uses it

Code:
()
Prgm
newdisp(100)
EndPrgm

So it should just display '100' on the home screen. I would think that the structure of the program would be something like


Code:
Func
newdisp(stuff)
Return Stuff
EndFunc

()
Prgm
newdisp(100)
EndPrgm


or maybe

Code:
()
Prgm
newdisp(100)
EndPrgm

Func
newdisp(stuff)
Return Stuff
EndFunc

But if this worked I would not be here...the above to codes I am writing in Ti GraphLink and then sending to my calculator.

Any thoughts?
 
Computer science news on Phys.org
  • #2
Any ideas on this one?
 

Related to Ti BASIC User defined fucntion use in a program

1. How do I create a user-defined function in Ti BASIC?

To create a user-defined function in Ti BASIC, use the "Define" command followed by the name of your function and the variables it takes in. For example, "Define myFunc(x,y) = x+y" would create a function called "myFunc" that takes in two variables, x and y, and returns their sum.

2. Can I use a user-defined function in a Ti BASIC program?

Yes, you can use a user-defined function in a Ti BASIC program. Simply call the function by using its name and passing in the necessary variables. For example, "myFunc(2,3)" would call the function "myFunc" with the values 2 and 3, and return the sum of these two values.

3. How do I edit a user-defined function in Ti BASIC?

To edit a user-defined function in Ti BASIC, use the "Edit" command followed by the name of the function you want to edit. This will open the function in the editor, where you can make any necessary changes.

4. Can I delete a user-defined function in Ti BASIC?

Yes, you can delete a user-defined function in Ti BASIC by using the "DelVar" command followed by the name of the function you want to delete. This will remove the function from your program and free up memory.

5. Are there any restrictions on user-defined functions in Ti BASIC?

Yes, there are a few restrictions when using user-defined functions in Ti BASIC. Functions cannot be recursive, meaning they cannot call themselves. Also, variables used in a function must be declared within the function or passed in as parameters. Finally, functions cannot have the same name as any built-in Ti BASIC commands or functions.

Similar threads

  • Computing and Technology
Replies
1
Views
2K
  • Computing and Technology
Replies
8
Views
9K
  • Programming and Computer Science
Replies
5
Views
1K
Replies
1
Views
1K
  • Programming and Computer Science
Replies
11
Views
2K
  • Computing and Technology
Replies
2
Views
731
  • Programming and Computer Science
Replies
16
Views
1K
  • Computing and Technology
Replies
2
Views
28K
  • STEM Academic Advising
Replies
12
Views
1K
  • Computing and Technology
Replies
1
Views
8K
Back
Top