Author Topic: Programming help  (Read 15443 times)

0 Members and 1 Guest are viewing this topic.

Offline titane666

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 8
  • Rating: +0/-0
    • View Profile
Re: Programming help
« Reply #15 on: May 05, 2010, 06:00:17 am »
I believed ti-basic was bound to memory-errors.
Is exiting a loop with a goto the only way to block memory ?
Even without blocks like that some scripts ends with a memory error :(
Anyway thanks for this information.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Programming help
« Reply #16 on: May 05, 2010, 01:07:21 pm »
The Goto instruction must never be put inside a While, Repeat, For() or If:Then/Else block. Otherwise, it never reaches the End instruction and the RAM that block took will not be freed up, thus, causing a memory leak and eventual ERR:MEMORY messages.

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Programming help
« Reply #17 on: May 05, 2010, 06:46:21 pm »
You can use it w/some unintended features of the parser (like how I implement subroutines), but yeah, you shouldn't ever unless you really know what you're doing. If you're not careful, it will be in a piece of infrequently executed code, and, just about as the player is about to get a high score after playing a few times for a few hours (must be a good game :)), BAM! ERR:MEMORY. And that would just suck. :)
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Programming help
« Reply #18 on: May 05, 2010, 07:15:34 pm »
Just curious, but what if you had a loop (While, Repeat, or For() and you put the Goto AND Lbl in the same loop, would that change anything? Just a random thought I just had.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Programming help
« Reply #19 on: May 05, 2010, 07:21:04 pm »
It would work, as long as the goto and the Lbl are in the same level of the code then everything will work great :)  The problem arises when you are goto-ing a place that is at a different level than where you start.  (and by level, i mean how many loops/if's you are inside)

Offline apcalc

  • The Game
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1393
  • Rating: +120/-2
  • VGhlIEdhbWUh (Base 64 :))
    • View Profile
Re: Programming help
« Reply #20 on: May 05, 2010, 07:21:33 pm »
Hi.  I have a program that uses Goto [whatever] in an If...EndIf block.    The code is below.  It is a [incomplete] Gas Laws program for the TI-Nspire.  Because this is a program and will end, and not keep playing like a game, will I use RAM memory.  Also, if this does use memory, could I fix it by making it go back to the original If...EndIf block with a lbl at the end of it and have it display the answer from there?  Thanks!

Code: [Select]
Define LibPub gaslaws()=
Prgm
:Local equ
:Text "Choose Equation-
(1) Boyle's Law
(2) Charles' Law
(3) Gay-Lussac's Law
(4) Avogadro's Law
(5) Ideal Gas Law
(6) Combined Gas Law
(7) Van der Waals' Equation
(8) Graham's Law"
:Request "Choose Equation:",equ
:If equ=1 Then
:Goto a
:ElseIf equ=2 Then
:Goto b
:ElseIf equ=3 Then
:Goto c
:ElseIf equ=4 Then
:Goto d
:ElseIf equ=5 Then
:Goto e
:ElseIf equ=6 Then
:Goto f
:ElseIf equ=7 Then
:Goto g
:ElseIf equ=8 Then
:Goto h
:EndIf
:Lbl a
:©Boyle's Law
:RequestStr "V1",v1
:RequestStr "V2",v2
:RequestStr "P1",p1
:RequestStr "P2",p2
:Disp "Answer: "&nSolve(expr(v1)*expr(p1)=expr(v2)*expr(p2),x)
:Lbl b
:©Charles' Law
:RequestStr "V1",v1
:RequestStr "V2",v2
:RequestStr "T1",t1
:RequestStr "T2",t2
:Disp "Answer: "&nSolve(((expr(v1))/(expr(t1)))=((expr(v2))/(expr(t2))),x)
:Lbl c
:©Gay-Lussac's Law
:Lbl d
:©Avogarro's Law
:RequestStr "V1",v1
:RequestStr "V2",v2
:RequestStr "n1",n1
:RequestStr "n2",n2
:Disp "Answer: "&nSolve(((expr(v1))/(expr(n1)))=((expr(v2))/(expr(n2))),x)
:Lbl e
:©Ideal Gas Law
:RequestStr "V1",v1
:RequestStr "V2",v2
:RequestStr "P1",p1
:RequestStr "P2",p2
:RequestStr "T1",t1
:RequestStr "T2",t2
:Disp "Answer: "&nSolve(((expr(v1)*expr(p1))/(expr(t1)))=((expr(v2)*expr(p2))/(expr(t2))),x)
:Lbl f
:©Combined Gas Law
:RequestStr "V1",v1
:RequestStr "V2",v2
:RequestStr "P1",p1
:RequestStr "P2",p2
:RequestStr "T1",t1
:RequestStr "T2",t2
:RequestStr "n1",n1
:RequestStr "n2",n2
:Disp "Answer: "&nSolve(((expr(v1)*expr(p1))/(expr(t1)*expr(n1)))=((expr(v2)*expr(p2))/(expr(t2)*expr(n2))),x)
:Lbl g
:©Van der Waals Equation
:Lbl h
:EndPrgm



Offline bwang

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 634
  • Rating: +30/-11
    • View Profile
Re: Programming help
« Reply #21 on: May 05, 2010, 07:51:47 pm »
Don't use goto in that program. Make the ElseIf blocks ElseIf...Then blocks and put your code between the Then and the next ElseIf.

Offline apcalc

  • The Game
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1393
  • Rating: +120/-2
  • VGhlIEdhbWUh (Base 64 :))
    • View Profile
Re: Programming help
« Reply #22 on: May 05, 2010, 07:59:38 pm »
That should make the program better.  Thanks for your help!  I have to finish this program fast before my Chemistry final.  I still have a long list of programs to go.
« Last Edit: May 05, 2010, 08:00:07 pm by apcalc »


Offline dislexicengineer

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 6
  • Rating: +0/-0
    • View Profile
Re: Programming help
« Reply #23 on: December 22, 2013, 07:37:18 pm »
That should make the program better.  Thanks for your help!  I have to finish this program fast before my Chemistry final.  I still have a long list of programs to go.

did you end up finishing that program?

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Programming help
« Reply #24 on: December 22, 2013, 07:42:37 pm »
Sadly I think he is no longer into calculator development. His last release was back in the Ndless 2.0 days, a few years ago, and he didn't post here for months. D:

Offline dislexicengineer

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 6
  • Rating: +0/-0
    • View Profile
Re: Programming help
« Reply #25 on: December 22, 2013, 09:22:36 pm »
damn, well thanks anyway! if you know if any complete chemistry apps. which include pH for the ti nspire. let me know! happy holidays!