Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: Deep Toaster on July 05, 2010, 11:25:02 pm

Title: Nspire lists
Post by: Deep Toaster on July 05, 2010, 11:25:02 pm
I just started coding Nspire BASIC, and it's been pretty easy since there are many areas where it's similar to TI-83 Plus BASIC. What I couldn't figure out, though, was how to access the elements of a list. I tried the 83+ syntax of parvar(3) where parvar is the list, but it only multiplies the list by three.

I've finished the program I was working on by using a combination of sum( and mid, as in sum(mid(parvar,3,1)), which, as you can probably tell, is really unoptimized, since it's basically taking the sum of a 1-element subset of the list, but it's the only way I've found to get what I want. It doesn't really matter, though, since the Nspire's speed more than accounts for the horrible improvisation, but I'm still wondering: Is there a way to access the list element directly? There aren't many guides on Nspire BASIC out there, and none of them explain lists very well.
Title: Re: Nspire lists
Post by: bwang on July 05, 2010, 11:27:04 pm
listname[n] retrieves the nth element of a list.
Title: Re: Nspire lists
Post by: Deep Toaster on July 05, 2010, 11:35:56 pm
Aug, I hate it when it's that simple >:( Thanks, though.
Title: Re: Nspire lists
Post by: willrandship on July 06, 2010, 01:04:59 am
yeah, you'll find a lot of things replace parentheses with brackets. Same with matrixes (I think that was my first thread on here :P)
Title: Re: Nspire lists
Post by: Builderboy on July 06, 2010, 01:12:47 am
I hate when i cant figure out how to do something and then its super easy :P When i was first learning to program i accessed lists with Prod(L1,N,N) XD
Title: Re: Nspire lists
Post by: bwang on July 06, 2010, 01:34:56 am
I hate when i cant figure out how to do something and then its super easy :P When i was first learning to program i accessed lists with Prod(L1,N,N) XD
LOL, I used to do that to.
Title: Re: Nspire lists
Post by: Deep Toaster on July 06, 2010, 01:40:00 am
I hate when i cant figure out how to do something and then its super easy :P

Same here. When I made my first game using string input, instead of If Str1=Str2, I used If inString(Str1,Str2) and inString(Str2,Str1) :P Never thought of the easiest things :)
Title: Re: Nspire lists
Post by: DJ Omnimaga on July 06, 2010, 01:45:33 am
yeah for me, when I do mistakes, it's often small stupid stuff. SOmetimes I'll also miss some obvious optimizations x.x
Title: Re: Nspire lists
Post by: calcdude84se on July 06, 2010, 02:16:58 pm
Interestingly, the 89/92/200 also uses brackets to index lists/matrices. :)
Title: Re: Nspire lists
Post by: apcalc on July 06, 2010, 02:21:19 pm
Interestingly, the 89/92/200 also uses brackets to index lists/matrices. :)

I think Nspire basic is a lot closer to 68k basic that it is to Z80.  Another similarity is that you can end a for loop on a Z80 calc with "End" but on the Nspire and 68k, you have to use "EndFor".  The only major differences are the lack of dialog boxes and any commands that can be used to make a decent basic game on the Nspire.
Title: Re: Nspire lists
Post by: DJ Omnimaga on July 06, 2010, 04:51:40 pm
Yeah true, I gave both 68k and Nspire basic a try before and they looked quite similar.

I wish both series had an input command that looked like Command Prompt/Consoles. It can be pretty handy if you make an old skool ASCII RPG like Medieva. ON 68k and Nspire the boxes that appears when using Input ruins everything...
Title: Re: Nspire lists
Post by: Deep Toaster on July 06, 2010, 11:04:16 pm
ON 68k and Nspire the boxes that appears when using Input ruins everything...

Nspire has a form of input? :o How do I use it? I was trying to find a command for it, but none of the 83+ style input commands (Prompt , Input , getKey, etc.) existed.

listname[n] retrieves the nth element of a list.

Now I have to remember to go back and change the code for every instance where the program accesses a list >:( At least the Nspire has a Find/Replace function.
Title: Re: Nspire lists
Post by: DJ Omnimaga on July 06, 2010, 11:07:11 pm
ON 68k and Nspire the boxes that appears when using Input ruins everything...

Nspire has a form of input? :o How do I use it? I was trying to find a command for it, but none of the 83+ style input commands (Prompt , Input , getKey, etc.) existed.
It was added in OS 2.0. I forgot the command name and syntax, though.
Title: Re: Nspire lists
Post by: apcalc on July 06, 2010, 11:11:31 pm
ON 68k and Nspire the boxes that appears when using Input ruins everything...


Nspire has a form of input? :o How do I use it? I was trying to find a command for it, but none of the 83+ style input commands (Prompt , Input , getKey, etc.) existed.
It was added in OS 2.0. I forgot the command name and syntax, though.

On the Nspire, you can use the Request or RequestStr (I think) command for input.  The syntax for both is:

Request [Text to display in dialog box (string)],[Variable you want to store it to (variable)]

Also, this will only work on OS 2.0 and above, as stated earlier
Title: Re: Nspire lists
Post by: DJ Omnimaga on July 06, 2010, 11:12:57 pm
Thanks for the command name ^^
Title: Re: Nspire lists
Post by: Deep Toaster on July 07, 2010, 06:16:02 am
ON 68k and Nspire the boxes that appears when using Input ruins everything...


Nspire has a form of input? :o How do I use it? I was trying to find a command for it, but none of the 83+ style input commands (Prompt , Input , getKey, etc.) existed.
It was added in OS 2.0. I forgot the command name and syntax, though.

On the Nspire, you can use the Request or RequestStr (I think) command for input.  The syntax for both is:

Request [Text to display in dialog box (string)],[Variable you want to store it to (variable)]

Also, this will only work on OS 2.0 and above, as stated earlier

Really? Finally, a real form of input! Thanks!
Title: Re: Nspire lists
Post by: DJ Omnimaga on July 17, 2010, 02:06:59 pm
Sadly, no getkey support yet :/

The good news, though, is that now we can have some forms of turn-based games. It just looks ugly when you can't have an input function that works like Command Prompt instead of a window/alert popping up. Basically, no Illusiat 81 :/

Btw, anyone knows if that input function redirects to the home screen or something when used? If for example someone displays a tilemap made of pixels and line commands, will using the input function switch to another view?