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
Liazon
title goes here


Bandwidth Hog


Joined: 01 Nov 2005
Posts: 2007

Posted: 02 Dec 2005 10:24:54 pm    Post subject:

So I've been getting bored again in my classes so I think I'll program a Basic RPG for my Ti-89.

I entered the following but it sent back an error message. Something about arguments.


Code:
While n!=13
Output a,47,"*"
getKey()->n
a-8(n=338)+24(n=338 and n=32)->a
a+8(n=344)-24(n=344 and n=32)->a
EndWhile


Any ideas?
Back to top
alexrudd
pm me if you read this


Bandwidth Hog


Joined: 06 Oct 2004
Posts: 2335

Posted: 02 Dec 2005 11:19:47 pm    Post subject:

I don't know much about 89 basic, but how can n be 338 and 32 at the same time?

On which line do you get the error?
Back to top
Liazon
title goes here


Bandwidth Hog


Joined: 01 Nov 2005
Posts: 2007

Posted: 02 Dec 2005 11:23:46 pm    Post subject:

My bad


Code:
While n!=13
Output a,47,"*"
getKey()
a-8(ans(1)=338)+24(ans(1)=338 and a=32)->a  //error line
a+8(ans(1)=344)-24(ans(1)=344 and a=32)->a  //error line
EndWhile
If a=48 Then
clrIO
clrHome
Stop
EndIf
If a=40 Then
//create all code needed for new game file, matrices, strings, etc. or reset them at least
EndIf
//Rest of the game goes here.


In case someone doesn't understand it, I'm trying to make an optimized menu screen with three options.

so it's like

title

* opt1
opt2
opt3

and the * can move up and down between all the options.

btw, on the 89T, you need both parentheses and quotes or the calc gets angry at you.


Last edited by Guest on 02 Dec 2005 11:28:46 pm; edited 1 time in total
Back to top
Jeremiah Walgren
General Operations Director


Know-It-All


Joined: 24 May 2003
Posts: 1937

Posted: 03 Dec 2005 12:41:34 am    Post subject:

What are you storing to ans(1)?

Also, if you could, post the exact wording of the error message.
Back to top
Fr0sty


Member


Joined: 27 Nov 2003
Posts: 202

Posted: 03 Dec 2005 02:47:46 pm    Post subject:

Does it have to do with implied multiplication? I haven't had mine for so long but Ti-89s don't really like A(B). They'd rather have A*(B).

Disabled emoticons.


Last edited by Guest on 03 Dec 2005 03:00:33 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: 03 Dec 2005 08:57:41 pm    Post subject:

Your problem is that on the TI-89, boolean expressions are not evaluated as 1 and 0, but rather as true and false. In general, you can write the function
Code:
Define bool(tf)=when(tf,1,0)
to convert from true and false to 1 and 0.

However, this is clumsy, and when() statements applied on a case-by-case basis can fix most problems. Including yours:


Code:
a+when(ans(1)=338,when(a=32,24,-8),0)->a


You don't always need to use when():


Code:
If ans(1)=338
a+when(a=32,24,-8)->a


Just so you know, expressions evaluated in programs don't modify ans(). Since arguments are much easier to pass, I can't think of a use for ans() in a program.


Last edited by Guest on 03 Dec 2005 09:00:55 pm; edited 1 time in total
Back to top
Liazon
title goes here


Bandwidth Hog


Joined: 01 Nov 2005
Posts: 2007

Posted: 03 Dec 2005 09:26:34 pm    Post subject:

Thanks. btw, is sub( still in 89 Basic?

and would the above code work on the 83+?
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 03 Dec 2005 10:01:19 pm    Post subject:

No, but there's a mid() function that works the same way. As well as left() and right() functions.

The above code wouldn't work on the 83+ due to the lack of a when( command.


Last edited by Guest on 03 Dec 2005 10:02:06 pm; edited 1 time in total
Back to top
Liazon
title goes here


Bandwidth Hog


Joined: 01 Nov 2005
Posts: 2007

Posted: 03 Dec 2005 10:51:29 pm    Post subject:

No, I meant the code I wrote. It looks like it should work.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 03 Dec 2005 10:53:36 pm    Post subject:

If you replace the commands and key values to the 83+ equivalents, yes.
Back to top
Liazon
title goes here


Bandwidth Hog


Joined: 01 Nov 2005
Posts: 2007

Posted: 06 Dec 2005 09:38:16 pm    Post subject:

I was looking through the 89T's manual and the only string manipulating functions were left and right. Maybe I missed one.

And is the unable to (un)archive programs and functions? just matrices, lists, strings, and variables.


Last edited by Guest on 06 Dec 2005 09:45:18 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: 06 Dec 2005 10:19:31 pm    Post subject:

Right on p.99 is a list of all the string functions.

& concatenate two strings, like + in TI-83+ basic. "hello"&"world" = "helloworld"
# indirection. Returns the value of the variable whose name is in the string. Use for primitive pointers and such.
char() char(n) returns the nth ASCII character.
dim() on the TI-89, this works for strings as well. Returns the length.
expr() evaluates the expression. Unlike the 83+, expression doesn't have to return a value i.e. expr("Line 0,0,1,1") is fine. Using colons you can have blocks. Useful for constructing variable dialogs.
format() puts a number in a format based on a format string, for detailed explanation see manual. Fancy version of string() below.
inString() inString(string, substring) returns the first occurrence of substring in string, or 0 if there isn't one.
left() returns a number of characters from the string, starting from the left.
mid() (string,start[,count]) returns count characters from string starting at start, or if count is omitted, all of them until the end.
ord() the ASCII value for the first character of the string.
right() returns a number of the rightmost characters from the string.
rotate() rotate(str,n) rotates str n characters left and wraps back. If n is negative, rotates right. default is -1, one rotation right.
shift() same thing, but instead of wrapping fills in new characters with spaces.
string() what we missed on the 83+, converts a number to a string.

Some of these have other purposes, such as for binary numbers or lists.
Back to top
Liazon
title goes here


Bandwidth Hog


Joined: 01 Nov 2005
Posts: 2007

Posted: 06 Dec 2005 11:01:04 pm    Post subject:

so essentially, strings are do not have a much greater advantage over matrices like they did on the 83+?
Back to top
threefingeredguy


Advanced Member


Joined: 01 Sep 2005
Posts: 479

Posted: 07 Dec 2005 01:03:46 am    Post subject:

I think they have more advantages, the rotation could come in handy in maps.
Back to top
Liazon
title goes here


Bandwidth Hog


Joined: 01 Nov 2005
Posts: 2007

Posted: 10 Dec 2005 12:16:34 am    Post subject:

but you can't do mid(mystring,1+1(a=1),3+5(a=1

you can't even leave out parenthesis and quotes!!

how would I use a string for a map on the 89? Right now I plan to use a 26x12 matrix to store map data. Will that be really slow?

@ Darkerline: you're right, programming on calc feels so much cooler Cool Cool
Back to top
bukwirm


Member


Joined: 06 Dec 2005
Posts: 233

Posted: 10 Dec 2005 02:22:13 am    Post subject:

Fr0sty wrote:
Does it have to do with implied multiplication? I haven't had mine for so long but Ti-89s don't really like A( B ). They'd rather have A*( B ).

Disabled emoticons.
[post="63165"]<{POST_SNAPBACK}>[/post]


Yes, the 89 intreprets A( B ) as calling functions A() with B as an argument. It will also interpret AB as a variable named "AB". You have to use A*B if you want multiplication.

There are a lot of optimization 'tricks' from the 83+ which do not work on the 89.


Last edited by Guest on 10 Dec 2005 02:24:26 am; 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: 10 Dec 2005 11:23:58 am    Post subject:

calcul831415 wrote:
but you can't do mid(mystring,1+1(a=1),3+5(a=1

you can't even leave out parenthesis and quotes!!

how would I use a string for a map on the 89?  Right now I plan to use a 26x12 matrix to store map data.  Will that be really slow?

@ Darkerline: you're right, programming on calc feels so much cooler  :cool:  :cool:
[post="63944"]<{POST_SNAPBACK}>[/post]

when(a=1,mid(mystring,2,8),mid(mystring(1,3))

You have considerable freedom in choosing data structures on the TI-89 (you could probably make a tree or a linked list if you wanted to). Strings and matrices both have their advantages.

Remember, you can have a matrix or a list of strings. Or even mix numbers and strings together.


Last edited by Guest on 10 Dec 2005 11:24:32 am; edited 1 time in total
Back to top
Liazon
title goes here


Bandwidth Hog


Joined: 01 Nov 2005
Posts: 2007

Posted: 10 Dec 2005 11:45:46 am    Post subject:

I guess when is really powerful. SO it's when(condition,do when true, do when false)?

Hey! i'm new even to the idea of using matrices for tile mapping. give me a break!


Last edited by Guest on 10 Dec 2005 11:46:28 am; 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: 10 Dec 2005 11:52:22 am    Post subject:

Exactly. You can even do
Code:
when(condition, true, false, undefined)
Example:

Code:
when(1/a>0,"positive","negative","zero")
This will work, because when a is not zero, 1/a will have the same sign as a. When a is zero, 1/a will return "undef", which will go to the third branch.

However, you can't put just anything into a when() command, it has to be or return a value. It's similar to the ? : command in C/C++.
Back to top
Liazon
title goes here


Bandwidth Hog


Joined: 01 Nov 2005
Posts: 2007

Posted: 10 Dec 2005 12:00:53 pm    Post subject:

This may sound stupid, but do you think xlib should be ported to Ti-89? I haven't done much experimentation with real Basic sprites on the 89.
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
    » Goto page 1, 2, 3  Next
» View previous topic :: View next topic  
Page 1 of 3 » All times are UTC - 5 Hours

 

Advertisement