Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / math, variable, result problem

Author
Message
Phrozin
21
Years of Service
User Offline
Joined: 16th Jun 2003
Location: Florida USA
Posted: 16th Feb 2004 15:31 Edited at: 16th Feb 2004 15:34
Heya's

I'm having a slight problem with a variable thats included in a mathematical problem, and the result is alsways 0. Here's the odd part, I know why it's returning zero! I just can't figure out how to fix it. Here are the parts:



Now, I don't have a Rpm variable declared because later on I use the keys to INC and DEC Rpm.



Now if I declare Rpm as something say Rpm=0, it will always remain 0 and never INC, or DEC because when it hit's the DO part of the loop it will reset Rpm to whatever I've declared it as.

Logically I've declared it just before the Sync command in the DO...Loop and still the same results. I know this is something really easy and simply has to be, but I can't see the trees for the forest.

Thanks for any help,
Phrozin

PS. A preview would be sweet on replies and posts
hexGEAR
22
Years of Service
User Offline
Joined: 3rd Nov 2002
Location: Naytonia
Posted: 16th Feb 2004 15:46
Firstly i'd advise declaring all the variables your going to use at the top of your program using LOCAL or GLOBAL.

Secondly your using an integer variable among real calculations, you need to make Rpm a real variable, Rpm#. In the second code snippet you even stated "Rpm<0.1" which is possible with only real variables.

I had the same problem, without declaring my variables, after every sync is done (i hope theres a sync in your loop ) all variables are reset to 0...

Phrozin
21
Years of Service
User Offline
Joined: 16th Jun 2003
Location: Florida USA
Posted: 16th Feb 2004 16:09 Edited at: 17th Feb 2004 04:36
Tried it, still wont INC or DEC. I can see why my brother is bald now. here's the source, I have a DO LOOP with sync in it, went from a sync rate or 60 to 30 with no change. I'm just sadly lost lol.



I'm sure I'm doing something horribly stupid, but I can't find it.

Thanks for your suggestion though Hexgear.

Phrozin


***Edit***
Nevermind, got it. had to declare Rpm# as Rpm# (Rpm#=Rpm#)
Now I have another problem, everything is working like I was thinking it would except.

If you look at my code I have Gear# decalring the different trans ratios, but when it actually gets going fast enough to change gears, the max speed stays the same even though gear ratio has been changed. Any idea's?

***Edit2***
Nevermind, forgot to replace 336 with Gear# in the Speed# Calc.
thanks though
TheCyborg
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 17th Feb 2004 14:50
Rpm#=Rpm# is not declaring a variable. You are just assigning the value already in the variable to the variable, wich is pointless.

To declare a variable, go to the VERY top of your program and use one of the following:

Local Rpm# As Float
or
Global Rpm# As Float


Also, I don't see the variables TireW#, TireH# and Rim# change during your program. If theese variables is not going to be chaned then move them to the VERY top of your code and declare them like above as constants, like this:

#Constant TireW# 275
#Constant TireH# 275*0.80
#Constant Rim# 22.5

Note, you should not use the equal-to symbol (=) in constant declaration.

Member of Tjald - Targeted Joint Addicted Liberation Diplomacy

I am (currently) 45% addicted to Counter-Strike. What about you?

Login to post a reply

Server time is: 2024-11-26 05:56:45
Your offset time is: 2024-11-26 05:56:45