Hello,

I need some help to correct my code pls.


Code:
ZStandard:ClrHome:ClrDraw:AxesOff:ExprOff:CoordOff:FnOff

Output(1,1,"Programado por:")
Output(2,1,"Carlos P. Fontes")
Output(3,2,"Eng-a Mecanica")
Output(4,6,"ISEC")
Output(5,6,"Data:")
Output(6,4,"07/02/2017")
Output(7,3,"Mec. Fluidos")
Output(8,4,"V.Beta-1.0")
Pause :ClrHome

Lbl 0:ClrHome:ClrDraw
Menu("Mec.FluidosISEC","Sair",99,"Pressao.mano",1,"Blco energtco",6,"Reynolds",7




Lbl 1
Text(2,2,"P.manometrica.Pm=rho*g*h"
Text(15,2,"Densidade.agua(10^3)"
Text(28,2,"Usa.se.p.1.fluido.parado"
Text(41,2,"enter.para.calculo.de.P"

Input "rho=",R
Input "g=",G
Input "h=",H

Text(2,2,"P=",R,"*",G,"*",H)
Text(15,2,"P=",R*G*H)
Pause :Goto 0

Lbl 6:
Text(2,2,"  P0+Ui^2+h1=Pf+Uf^2+hf+HL"
Text(8,2,"  --    ---                 --    ---    "
Text(12,2,"  gamma        2g                   gamma            2g "
Pause



Disp "Pressao inicial"
Input "Pi=",A
Disp "Densidade especifica"
Input "rho*10^3=",B
Disp "velocidade inicial"
Input "Ui=",C
Disp "altura inicial"
Input "hi=",D
Disp "Pressao final"
Input "Pf=",E
Disp "Velocidade final"
Input "Uf=",F
Disp "Altura final"
Input "hf=",G
Pause :Goto 10

Lbl 10 :ClrHome:ClrDraw
Text(2,2,"Head losses=",D,"-",G,"
Pause
Text(15,2,"Hl=",D-G

Pause :Goto 0




Lbl 7
Text(2,2,"Nro de Reynolds"
Text(15,2,"Re=(rho*v*D)/u"
Text(28,2,"v=velocidade de escoamento"
Text(41,2,"u=viscosidade dinamica"
Text(54,2,"D=diametro do tubo"

Pause :Goto 0

Lbl 99:ClrHome:ClrDraw:AxesOn:ExprOn:CoordOn:FnOn :ZStandard:Output(1,1,"")
This code looks good! (Except for the last Lbl, is supposed to be Lbl99 ?) I don't understand any of the words, but that is fine :

I am not an expert or anything though...
Portuguese words!! Lbl 99 is to go out. This code is for a ti 84 plus calculator...
Were you having problems with the code, or did you just want someone to review it?

You use ClrHome a few extra time though Very Happy
Is the program supposed to pause twice after Labels 7 and 10?
bluswimmer wrote:
Is the program supposed to pause twice after Labels 7 and 10?


Do you think, that is my error?? aah will see

on my TI the error is right after this

Input "hf=",G

Error # 514 Basic Ex Err:SYN

Could you tell why sometimes, the same code runs sometimes and the exactly same code sometimes show me an error?????

edit by Alex: Post merge.
Your code seems like it would work fine. There are some little optimizations here and there, but overall, it seems alright. One thing you may want to note is the way your program flows. You have a handful of gotos and labels, and that kind of makes what is known as spaghetti code. In this particular case, it isn't too bad, but as you might imagine, with longer programs, it can get very confusing. Also, this:
Code:
Pause :Goto 3
Lbl 3

You can see that if you remove the Goto, the program will keep on going right to Lbl 3, and since you only goto that label once, you could remove it entirely and just do this

Code:
Pause

Same thing goes for most other labels. If you remove the labels entirely, since you never actually need to jump to the label, it will still work fine. If you use labels as a sort of way to comment your code, you should be advised that in SourceCoder, I think putting "//" indicates a comment. This won't make a big difference, but it is good practice to try and not use those commands too much, because it is generally quite slow, it can cause memory leaks if used inadequately, and can make your code more complicated than it has to be. Here is the code if you remove the useless jumps:

Code:
ZStandard:ClrHome:ClrDraw:AxesOff:ExprOff:CoordOff:FnOff

Output(1,1,"Programado por:")
Output(2,1,"Carlos P. Fontes")
Output(3,2,"Eng-a Mecanica")
Output(4,6,"ISEC")
Output(5,6,"Data:")
Output(6,4,"07/02/2017")
Output(7,3,"Mec. Fluidos")
Output(8,4,"V.Beta-1.0")
Pause :ClrHome

ClrHome:ClrDraw
Menu("Mec.FluidosISEC","Sair",99,"Pressao.mano",1,"Blco energtco",6,"Reynolds",7


Text(2,2,"P.manometrica.Pm=rho*g*h"
Text(15,2,"Densidade.agua(10^3)"
Text(28,2,"Usa.se.p.1.fluido.parado"
Text(41,2,"enter.para.calculo.de.P"
Pause

ClrHome:ClrDraw
Input "rho=",R
Input "g=",G
Input "h=",H
Pause

Text(2,2,"P=",R,"*",G,"*",H)
Text(15,2,"P=",R*G*H)
Pause :ClrTable:Goto 0

Text(2,2,"  P0+Ui^2+h1=Pf+Uf^2+hf+HL"
Text(8,2,"  --    ---                 --    ---    "
Text(12,2,"  gamma        2g                   gamma            2g "
Pause

Disp "Pressao inicial"
Input "Pi=",A
Disp "Densidade especifica"
Input "rho*10^3=",B
Disp "velocidade inicial"
Input "Ui=",C
Disp "altura inicial"
Input "hi=",D
Disp "Pressao final"
Input "Pf=",E
Disp "Velocidade final"
Input "Uf=",F
Disp "Altura final"
Input "hf=",G
Pause

Text(2,2,"Head losses=",D,"-",G,"
Pause
Pause :Goto 0



Text(2,2,"Nro de Reynolds"
Text(15,2,"Re=(rho*v*D)/u"
Text(28,2,"v=velocidade de escoamento"
Text(41,2,"u=viscosidade dinamica"
Text(54,2,"D=diametro do tubo"
Pause

Pause :Goto 0

ClrHome:ClrDraw:AxesOn:ExprOn:CoordOn:FnOn :ZStandard:Output(1,1,"")

As for the Input, that is the proper syntax for that command. I Would suggest you make sure that the actual Input token is being used rather than having it typed out in letters, as that would cause an error. This can happen if you export your code from an editor who for various reasons, didn't convert the characters to the token.

EDIT: OH GOD, I'VE DUN GOOFED!
don't remove the labels. I didn't notice there was a Menu() command.
mr womp womp

If u remove the Lbl the menu does not work.... Do u have a ti 84 plus ? I am a begginner ...
Don't remove all of the Labels. Keep the ones that the menu uses (99,1,6,7) and you can probably get rid of the rest of them Very Happy
My code is running, but the text is appearing on on top of the others...
Pintasman wrote:
My code is running, but the text is appearing on on top of the others...

I'd recommend using ClrDraw to get rid of the text you don't want.
Do u know some mechanical engineers in this forum?
bluswimmer wrote:
Pintasman wrote:
My code is running, but the text is appearing on on top of the others...

I'd recommend using ClrDraw to get rid of the text you don't want.


ClrDraw where? how to use?
Pintasman wrote:
ClrDraw where? how to use?

There's this wonderful thing called Google you should try to use more often Smile Also, your above code already uses ClrDraw; so either that is not your code or you are just trolling. Regardless, please try not to post twice in a row within 24 hours, simply edit your previous post. Thank you, and welcome! Smile
MateoConLechuga wrote:
Pintasman wrote:
ClrDraw where? how to use?

There's this wonderful thing called Google you should try to use more often Smile Also, your above code already uses ClrDraw; so either that is not your code or you are just trolling. Regardless, please try not to post twice in a row within 24 hours, simply edit your previous post. Thank you, and welcome! Smile
This is my code, but sometimes it runs well, and sometimes does not.... Very Happy
It seems that you're learning the TI-Basic language - if so, we would be glad to help you.
For first, I would suggest looking over at TI-Basic Developer which is a really valuable resource for any kind of command you want to look up - it helped myself a lot when I was first learning the language.
And second, feel free to post anything you don't understand here, and we'll be glad to help out where we can. I think I won't be mistaken if I say that there are some of the world's best calculator programmers on this site!
Nik wrote:
It seems that you're learning the TI-Basic language - if so, we would be glad to help you.
For first, I would suggest looking over at TI-Basic Developer which is a really valuable resource for any kind of command you want to look up - it helped myself a lot when I was first learning the language.
And second, feel free to post anything you don't understand here, and we'll be glad to help out where we can. I think I won't be mistaken if I say that there are some of the world's best calculator programmers on this site!


Thank u very much, Do u know anything about Mechanical engineering?
Pintasman wrote:
Thank u very much, Do u know anything about Mechanical engineering?

This depends very much on what exactly you need, but I suggest asking about that in your other topic.
  
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
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement