Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
25 May, 2013, 07:03:09 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1]   Go Down
  Print  
Author Topic: 83+ to nspire nx rewrite fail -  (Read 429 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
ShortsOnFire79
LV1 Newcomer (Next: 20)
*
Offline Offline

Gender: Male
Last Login: 12 April, 2012, 16:02:45
Date Registered: 25 March, 2012, 03:07:37
Location: California
Posts: 5


Topic starter
Total Post Ratings: 0

View Profile WWW
« on: 26 March, 2012, 06:07:44 »
0

Hey,

So I'm in the process of rewriting some of my more useful programs from my TI-83 plus onto my TI-nspire cx cas.
I've written myself a program that will ask for 4 variables, and depending on which variable is set as the one to solve for, it will perform a certain equation.  By making my variables equal each other (ex: p=p) then that tells my code to solve for that variable.

Heres the code thats on my 83, it works just fine.
Spoiler for Hidden:
:Disp "pv=(0.08206)nt"
:Input "enter p:atm=",p
:Input "enter v:l=",v
:Input "enter n=",n
:Input "enter t:k=",t
:If p=p:then
:Disp (0.08206nt)/v
:If v=v:then
:Disp (0.08206nt)/p
:If n=n:then
:Disp (pv)/(0.08206t0
:If t=t:then
:Disp (pv)/(n0.08206)

I'm basically writing the same exact code, except without the 'input' command, since it isn't in the catalog function on the cas, but that is what the 'define' command is for.  Here is the code I have on my cas, it gives me syntax errors when I try to 'check it', and when I run it, it says I have too many arguments.  I also tried writing the code with instead of 'func', using 'prgm', which didn't change anything.  I attempted to have the code recognize the variable '?' which would symbolize which variable to solve for, but it would not recognize it either.
Spoiler for Hidden:
Define gaslaw(p,v,n,t)=
func
If p=p, then disp 0.08206nt/v
If v=v, then disp 0.08206nt/p
If n=n, then disp pv/0.08206t
If t=t, then disp pv/0.08206n
endfunc

I know that my knowledge of coding is quite diminutive, which is why I'm here, to learn.  So feel free to poke and make fun of my codes and how sloppy it is and whatnot.  I'm sure there are numerous ways to shorten my code, but I only know the very basics at the moment.  Any bits of knowledge you could offer me would be greatly received, I am here to learn!

Thank you for your time. Smiley
Logged
ElementCoder
LV6 Super Member (Next: 500)
******
Offline Offline

Gender: Male
Last Login: Yesterday at 22:23:52
Date Registered: 22 May, 2011, 17:28:58
Location: Netherlands, Drachten
Posts: 411


Total Post Ratings: +26

View Profile
« Reply #1 on: 26 March, 2012, 11:14:46 »
+1

First of all, input can be gained from the Request (for numerical values) and RequestStr (for strings).
The major problem that's causing all the trouble is that you don't close the if statements.
On the TI-Nspire you have to do this:
Spoiler for Hidden:
If <condition> then
<actions to perform>
EndIf

Also, all the variables are ALWAYS equal to themselves. So v=v no matter what. So you will always get four results.
Here's how I would've done it:
Spoiler for Hidden:
Your code, but with closed if statments. Will always return four answers
Spoiler for Hidden:
Define gaslaw(p,v,n,t)=
Prgm
If p=p Then
 Disp ((0.08206*n*t)/(v))
EndIf
If v=v Then
 Disp ((0.08206*n*t)/(p))
EndIf
If n=n Then
 Disp ((p*v)/(0.08206))*t
EndIf
If t=t Then
 Disp ((p*v)/(0.08206))*n
EndIf
EndPrgm

Another option: make the variable to solve different from the others. The gaslaw for example would never have negative numbers or zero, so consider this (Stop terminates the program):
Spoiler for Hidden:
Define gaslaw(p,v,n,t)=
Prgm
If p<0 Then
 Disp ((0.08206*n*t)/(v))
 Stop
EndIf
If v<0 Then
 Disp ((0.08206*n*t)/(p))
 Stop
EndIf
If n<0 Then
 Disp ((p*v)/(0.08206))*t
 Stop
EndIf
If t<0 Then
 Disp ((p*v)/(0.08206))*n
 Stop
EndIf
EndPrgm

Personally, I would do this:
Spoiler for Hidden:
Define gaslaw(p,v,n,t)=
Prgm
If p=0 Then
 Disp "p=",((0.08206*n*t)/(v))
ElseIf v=0 Then
 Disp "v=",((0.08206*n*t)/(p))
ElseIf n=0 Then
 Disp "n=",((p*v)/(0.08206))*t
ElseIf t=0 Then
 Disp "t=",((p*v)/(0.08206))*n
Else
 Disp "Error: nothing to solve, check syntax."
EndIf
EndPrgm

Finally, not really needed, if you want nice input:
Spoiler for Hidden:
Define gaslaw(p,v,n,t)=
Prgm
Request "Enter p:atm=",p
Request "Enter v:l=:",p
Request "Enter n=",n
Request "Enter t:k=:

If p=0 Then
 Disp "p=",((0.08206*n*t)/(v))
ElseIf v=0 Then
 Disp "v=",((0.08206*n*t)/(p))
ElseIf n=0 Then
 Disp "n=",((p*v)/(0.08206))*t
ElseIf t=0 Then
 Disp "t=",((p*v)/(0.08206))*n
Else
 Disp "Error: nothing to solve, check syntax."
EndIf
EndPrgm

I hope this was helpful. And if you want to learn, check my tutorial (link coming soon in my sig)
« Last Edit: 26 March, 2012, 11:28:25 by ElementCoder » Logged

Calculators owned: TI-Nspire ClickPad (no batteries though Tongue); TI-Nspire CX
Known languages: TI BASIC (Nspire); Java; Lua; C++
Spoiler for Random stuff:

NerdTests.com says I'm a Nerd God.  Click here to take the Nerd Test, get nerdy images and jokes, and write on the nerd forum!


Omni search is down, use http://megapowers.net/v/search.htm instead.
Jonius7
aka jhgenius
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: 20 May, 2013, 06:58:52
Date Registered: 03 September, 2010, 02:50:11
Location: Gold Coast, Australia
Posts: 1743


Total Post Ratings: +50

View Profile WWW
« Reply #2 on: 26 March, 2012, 12:00:17 »
0

Yeah TI-nspire Basic Code is different and cannot be written as concisely as Code on the TI-83+.
I'm actually surprised that the TI-83+ Code actually works. I didn't know that EndIfs were not needed.

And Hi ElementCoder! I'm Jonius7, also known as jhgenius01 (you would have visited my website at jhgenius01.webs.com)
Haven't really seen you around that much, but good to see you!
Wonder if superbany has an account here.
« Last Edit: 26 March, 2012, 12:01:22 by Jonius7 » Logged



Userbars.com is down?
+9001
Intermediate TI-nspire Basic Programmer
Programmed some CASIO Basic in the past
DJ_O Music Discographist Wink
Userbars for these coming... in the process

My Released and Announced Projects (Updated 2013/01/29)
TI-nspire BASIC
TI-nspire Hold 'em | Health Bar | Scissors Paper Rock | Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled)

TI-nspire Lua
Numstrat | TI-nspire Hold 'em Lua | Terraria (coming soon)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Spoiler for Other Stuff:
Spoiler for Want your own HonestDownloads userbar?:
Hello! Do you want to show your affection for my website, HonestDownloads? Then here is a userbar I specially created earlier just for HonestDownloads users!

To add it to your signature just copy and paste the code below into your sig and you'll become an instant supporter of my website!

1
[URL=http://www.jhgenius01.webs.com][IMG]http://s1.bild.me/bilder/060112/3684792HDuserbaruser.png[/IMG][/URL]
Spoiler for My TI-nspire Basic Programs (Updated 2012/04/15):
***List of Programs in the TI-nspire Stadium***
Group Release 2012/04/07 on omnimaga.org

Games
   Noteable Release    ticalc.org Release Development/Not Publicly Released
2010/05/08 TI-nspire Hold 'em
   2012/04/07 v1.1.2   2012/04/10 v1.1.3  2012/04/14 v1.2.1
2010/08/03 Cosmic Legions
   2012/04/07 v0.2.2.2 (1st Release)
2010/08/12 Battle of 16s
   2012/04/07 v0.2.7
2010/09/10 Health Bar
   2012/04/07 v1.2     2012/04/02 v1.0   
2010/12/04 sTIck RPG
   2012/04/07 v0.1.5.2
2011/01/09 Monopoly
   2012/04/07 v0.16    (1st Release)
2012/04/09 Scissors Paper Rock
   2012/04/14 v0.8.1

Miscellaneous
2010/11/07 中文 (Chinese) Demonstration
   2012/04/07 v1.3     (1st Release)

Potential/Minor Programs
2010/09/26 Shanghai Metro
   2012/04/07 v0.2     (1st Release)
2010/12/22 TI-nspire Programming Tutorials
   2012/04/07 v0.1     (1st Release)
2010/12/28 Casino Games
   Was not released.
2011/04/22 Interlink
   2012/04/07 v0.0.4   (1st Release)
2012/03/22 Hierarchy
   2012/04/07 v0.01

Demo Programs (some may become Potential Programs)
2010/06/23 Monopoly (Board)
   2012/04/07 Prototype
2010/07/14 Strategy Battle
   2012/04/07 v0.12
2010/10/05 JRPG
   2012/04/07 v0.2
2010/11/02 PlotGrid
   2012/04/07 v0.2
2010/11/24 civilizaTIon™
   2012/04/07 v0.11

Purely Informational
2011/01/05 TI-nspire Stadium Changelog
   2012/04/07 v2
   Created to list significant releases of my programs. A page similar to this List of Programs in the TI-nspire Stadium was included in the documentation of most of my programs until sometime in Late 2011/Early 2012.

All games and programs coded in TI-nspire Basic.
© 2010-2012 Jason Ho.
Last Updated 14 April 2012

jhgenius01.webs.com
Will be moving! Stay tuned for updates.
Spoiler for Progress of Doodle God Axe:
2011/12/21 4% - Progress Suspended, ideas of graphical sprites still uncertain
Spoiler for Other Other You Know What Other Stuff I'm Talking About Stuff Stuff (Updated 2012/01/17):
ShortsOnFire79
LV1 Newcomer (Next: 20)
*
Offline Offline

Gender: Male
Last Login: 12 April, 2012, 16:02:45
Date Registered: 25 March, 2012, 03:07:37
Location: California
Posts: 5


Topic starter
Total Post Ratings: 0

View Profile WWW
« Reply #3 on: 27 March, 2012, 02:00:22 »
0

First of all, input can be gained from the Request (for numerical values) and RequestStr (for strings).
The major problem that's causing all the trouble is that you don't close the if statements.
On the TI-Nspire you have to do this:
Spoiler for Hidden:
If <condition> then
<actions to perform>
EndIf

Personally, I would do this:
Spoiler for Hidden:
Define gaslaw(p,v,n,t)=
Prgm
If p=0 Then
 Disp "p=",((0.08206*n*t)/(v))
ElseIf v=0 Then
 Disp "v=",((0.08206*n*t)/(p))
ElseIf n=0 Then
 Disp "n=",((p*v)/(0.08206))*t
ElseIf t=0 Then
 Disp "t=",((p*v)/(0.08206))*n
Else
 Disp "Error: nothing to solve, check syntax."
EndIf
EndPrgm
I hope this was helpful. And if you want to learn, check my tutorial (link coming soon in my sig)

Thanks for walking me through the if-thens, that'll be really helpful on my next project.

I ended up using your code that you personally would use.  Works great!  One thing I don't understand though, is why at the second to last line, you have an EndIf?  Is that to tell the code to end, if the previous error was witnessed?

Also, what will your tutorials be covering?  If they're as descriptive as the post you left me, I will surely check them out! Thank you!
Logged
chattahippie
LV6 Super Member (Next: 500)
******
Offline Offline

Gender: Male
Last Login: 27 March, 2013, 05:21:38
Date Registered: 19 July, 2011, 04:13:49
Location: Somewhere
Posts: 358


Total Post Ratings: +27

View Profile
« Reply #4 on: 27 March, 2012, 02:12:36 »
0

If <condition> then
<actions to perform>
EndIf

From this code example, the EndIf is a command that Ends the If statement
Logged
Jonius7
aka jhgenius
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: 20 May, 2013, 06:58:52
Date Registered: 03 September, 2010, 02:50:11
Location: Gold Coast, Australia
Posts: 1743


Total Post Ratings: +50

View Profile WWW
« Reply #5 on: 27 March, 2012, 13:53:05 »
0

Is EndIf or End not required in TI-BASIC (83/84)?
I know that End is required in Casio Basic and EndIf in TI-nspire Basic
End (for function in Lua) too.
« Last Edit: 27 March, 2012, 13:53:24 by Jonius7 » Logged



Userbars.com is down?
+9001
Intermediate TI-nspire Basic Programmer
Programmed some CASIO Basic in the past
DJ_O Music Discographist Wink
Userbars for these coming... in the process

My Released and Announced Projects (Updated 2013/01/29)
TI-nspire BASIC
TI-nspire Hold 'em | Health Bar | Scissors Paper Rock | Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled)

TI-nspire Lua
Numstrat | TI-nspire Hold 'em Lua | Terraria (coming soon)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Spoiler for Other Stuff:
Spoiler for Want your own HonestDownloads userbar?:
Hello! Do you want to show your affection for my website, HonestDownloads? Then here is a userbar I specially created earlier just for HonestDownloads users!

To add it to your signature just copy and paste the code below into your sig and you'll become an instant supporter of my website!

1
[URL=http://www.jhgenius01.webs.com][IMG]http://s1.bild.me/bilder/060112/3684792HDuserbaruser.png[/IMG][/URL]
Spoiler for My TI-nspire Basic Programs (Updated 2012/04/15):
***List of Programs in the TI-nspire Stadium***
Group Release 2012/04/07 on omnimaga.org

Games
   Noteable Release    ticalc.org Release Development/Not Publicly Released
2010/05/08 TI-nspire Hold 'em
   2012/04/07 v1.1.2   2012/04/10 v1.1.3  2012/04/14 v1.2.1
2010/08/03 Cosmic Legions
   2012/04/07 v0.2.2.2 (1st Release)
2010/08/12 Battle of 16s
   2012/04/07 v0.2.7
2010/09/10 Health Bar
   2012/04/07 v1.2     2012/04/02 v1.0   
2010/12/04 sTIck RPG
   2012/04/07 v0.1.5.2
2011/01/09 Monopoly
   2012/04/07 v0.16    (1st Release)
2012/04/09 Scissors Paper Rock
   2012/04/14 v0.8.1

Miscellaneous
2010/11/07 中文 (Chinese) Demonstration
   2012/04/07 v1.3     (1st Release)

Potential/Minor Programs
2010/09/26 Shanghai Metro
   2012/04/07 v0.2     (1st Release)
2010/12/22 TI-nspire Programming Tutorials
   2012/04/07 v0.1     (1st Release)
2010/12/28 Casino Games
   Was not released.
2011/04/22 Interlink
   2012/04/07 v0.0.4   (1st Release)
2012/03/22 Hierarchy
   2012/04/07 v0.01

Demo Programs (some may become Potential Programs)
2010/06/23 Monopoly (Board)
   2012/04/07 Prototype
2010/07/14 Strategy Battle
   2012/04/07 v0.12
2010/10/05 JRPG
   2012/04/07 v0.2
2010/11/02 PlotGrid
   2012/04/07 v0.2
2010/11/24 civilizaTIon™
   2012/04/07 v0.11

Purely Informational
2011/01/05 TI-nspire Stadium Changelog
   2012/04/07 v2
   Created to list significant releases of my programs. A page similar to this List of Programs in the TI-nspire Stadium was included in the documentation of most of my programs until sometime in Late 2011/Early 2012.

All games and programs coded in TI-nspire Basic.
© 2010-2012 Jason Ho.
Last Updated 14 April 2012

jhgenius01.webs.com
Will be moving! Stay tuned for updates.
Spoiler for Progress of Doodle God Axe:
2011/12/21 4% - Progress Suspended, ideas of graphical sprites still uncertain
Spoiler for Other Other You Know What Other Stuff I'm Talking About Stuff Stuff (Updated 2012/01/17):
ElementCoder
LV6 Super Member (Next: 500)
******
Offline Offline

Gender: Male
Last Login: Yesterday at 22:23:52
Date Registered: 22 May, 2011, 17:28:58
Location: Netherlands, Drachten
Posts: 411


Total Post Ratings: +26

View Profile
« Reply #6 on: 27 March, 2012, 16:15:01 »
0

Also, what will your tutorials be covering?  If they're as descriptive as the post you left me, I will surely check them out! Thank you!

I plan to make them as descriptive as my post, with useful examples and quizes to test knowledge Tongue

@Jonius7: yeah, lets say I took a forced break. School and such, and with exams upcoming I don't know how much time I can spend around here and coding stuff. I'm doing a little too much atm so I'm a bit I must have had too much radiation for breakfast... (learning java, learning lua (does anyone know a good tutorial?), playing a lot of guitar Tongue)
Logged

Calculators owned: TI-Nspire ClickPad (no batteries though Tongue); TI-Nspire CX
Known languages: TI BASIC (Nspire); Java; Lua; C++
Spoiler for Random stuff:

NerdTests.com says I'm a Nerd God.  Click here to take the Nerd Test, get nerdy images and jokes, and write on the nerd forum!


Omni search is down, use http://megapowers.net/v/search.htm instead.
Jonius7
aka jhgenius
LV10 31337 u53r (Next: 2000)
**********
Offline Offline

Gender: Male
Last Login: 20 May, 2013, 06:58:52
Date Registered: 03 September, 2010, 02:50:11
Location: Gold Coast, Australia
Posts: 1743


Total Post Ratings: +50

View Profile WWW
« Reply #7 on: 28 March, 2012, 02:11:25 »
0

Yeah, true, posting posts and stuff is definitely time consuming. But I've been here a while, so I guess it's not too bad. Just that I need some good projects!
Logged



Userbars.com is down?
+9001
Intermediate TI-nspire Basic Programmer
Programmed some CASIO Basic in the past
DJ_O Music Discographist Wink
Userbars for these coming... in the process

My Released and Announced Projects (Updated 2013/01/29)
TI-nspire BASIC
TI-nspire Hold 'em | Health Bar | Scissors Paper Rock | Battle of 16s (stalled) | sTIck RPG (stalled) | Monopoly (stalled)

TI-nspire Lua
Numstrat | TI-nspire Hold 'em Lua | Terraria (coming soon)
Axe Parser
Doodle God (stalled while I go and learn some Axe)

Spoiler for Other Stuff:
Spoiler for Want your own HonestDownloads userbar?:
Hello! Do you want to show your affection for my website, HonestDownloads? Then here is a userbar I specially created earlier just for HonestDownloads users!

To add it to your signature just copy and paste the code below into your sig and you'll become an instant supporter of my website!

1
[URL=http://www.jhgenius01.webs.com][IMG]http://s1.bild.me/bilder/060112/3684792HDuserbaruser.png[/IMG][/URL]
Spoiler for My TI-nspire Basic Programs (Updated 2012/04/15):
***List of Programs in the TI-nspire Stadium***
Group Release 2012/04/07 on omnimaga.org

Games
   Noteable Release    ticalc.org Release Development/Not Publicly Released
2010/05/08 TI-nspire Hold 'em
   2012/04/07 v1.1.2   2012/04/10 v1.1.3  2012/04/14 v1.2.1
2010/08/03 Cosmic Legions
   2012/04/07 v0.2.2.2 (1st Release)
2010/08/12 Battle of 16s
   2012/04/07 v0.2.7
2010/09/10 Health Bar
   2012/04/07 v1.2     2012/04/02 v1.0   
2010/12/04 sTIck RPG
   2012/04/07 v0.1.5.2
2011/01/09 Monopoly
   2012/04/07 v0.16    (1st Release)
2012/04/09 Scissors Paper Rock
   2012/04/14 v0.8.1

Miscellaneous
2010/11/07 中文 (Chinese) Demonstration
   2012/04/07 v1.3     (1st Release)

Potential/Minor Programs
2010/09/26 Shanghai Metro
   2012/04/07 v0.2     (1st Release)
2010/12/22 TI-nspire Programming Tutorials
   2012/04/07 v0.1     (1st Release)
2010/12/28 Casino Games
   Was not released.
2011/04/22 Interlink
   2012/04/07 v0.0.4   (1st Release)
2012/03/22 Hierarchy
   2012/04/07 v0.01

Demo Programs (some may become Potential Programs)
2010/06/23 Monopoly (Board)
   2012/04/07 Prototype
2010/07/14 Strategy Battle
   2012/04/07 v0.12
2010/10/05 JRPG
   2012/04/07 v0.2
2010/11/02 PlotGrid
   2012/04/07 v0.2
2010/11/24 civilizaTIon™
   2012/04/07 v0.11

Purely Informational
2011/01/05 TI-nspire Stadium Changelog
   2012/04/07 v2
   Created to list significant releases of my programs. A page similar to this List of Programs in the TI-nspire Stadium was included in the documentation of most of my programs until sometime in Late 2011/Early 2012.

All games and programs coded in TI-nspire Basic.
© 2010-2012 Jason Ho.
Last Updated 14 April 2012

jhgenius01.webs.com
Will be moving! Stay tuned for updates.
Spoiler for Progress of Doodle God Axe:
2011/12/21 4% - Progress Suspended, ideas of graphical sprites still uncertain
Spoiler for Other Other You Know What Other Stuff I'm Talking About Stuff Stuff (Updated 2012/01/17):
chattahippie
LV6 Super Member (Next: 500)
******
Offline Offline

Gender: Male
Last Login: 27 March, 2013, 05:21:38
Date Registered: 19 July, 2011, 04:13:49
Location: Somewhere
Posts: 358


Total Post Ratings: +27

View Profile
« Reply #8 on: 28 March, 2012, 03:24:06 »
0

Is EndIf or End not required in TI-BASIC (83/84)?
I know that End is required in Casio Basic and EndIf in TI-nspire Basic
End (for function in Lua) too.


84+ only uses End, there is no such thing as EndIf (unless you use Axe Tongue )
Logged
cyanophycean314
LV6 Super Member (Next: 500)
******
Offline Offline

Gender: Male
Last Login: 03 May, 2013, 19:28:34
Date Registered: 07 December, 2011, 02:44:32
Location: Somewhere?
Posts: 363


Total Post Ratings: +42

View Profile
« Reply #9 on: 28 March, 2012, 04:27:59 »
0

learning lua (does anyone know a good tutorial?)

For Lua, first learn Lua itself, http://www.lua.org/pil/
Then, head to Inspired Lua for Nspire API, www.inspired-lua.org

Good luck!
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.447 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.