Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   why does aux1 doesn't work? (http://www.chiefdelphi.com/forums/showthread.php?t=53417)

HellBoy 04-02-2007 06:11

why does aux1 doesn't work?
 
Here is the code and from some reason doesn't work.
Code:

if(p1_sw_aux1==1)
{
g=1;
}
if(g==1)
{
z++;
}
if((z<=30)&&(a==1))
{
relay1_fwd=1;
}
else
a=0;


Joe Ross 04-02-2007 10:11

Re: why does aux1 doesn't work?
 
First of all, it would help if you explained what you wanted the code to do. Secondly, it would help to describe what you've proven works or doesn't work. For example, have you used this code with another switch and it worked correctly? Have verified that p1_sw_aux1 doesn't switch, or do you not really know?

If I had to guess at what the problem is with no other information, I'd say that z (and maybe some of the other variables, depending on the rest of your code) are not declared static.

HellBoy 04-02-2007 10:51

Re: why does aux1 doesn't work?
 
I tried to turn the Globe engine for 0.8 seconds when I press aux1.
Appearently, it doesn't work even the variables are declered as static.
Is the code correct?

paulcd2000 04-02-2007 11:22

Re: why does aux1 doesn't work?
 
is "a" initialized as 1?

As a side note,
Code:

if(g==1)
{
z++;
}

can be written as
Code:

if(g)
z++;

just to save time (but some people don't like it). same with everything else that will only be 1 or 0. the brackets are only needed if there is more than 1 line of code.

Bomberofdoom 04-02-2007 11:31

Re: why does aux1 doesn't work?
 
I'm working with him on the code and a is intializied as 1. Should all the int varibles be static?

Alan Anderson 04-02-2007 12:11

Re: why does aux1 doesn't work?
 
Quote:

Originally Posted by HellBoy (Post 571429)
I tried to turn the Globe engine for 0.8 seconds when I press aux1.
Appearently, it doesn't work even the variables are declered as static.
Is the code correct?

At the very least, it is incomplete.

What does happen when you press aux1? Does the Globe motor start running and never stop? There is nothing in your code to turn it off after the time has elapsed.

Xenosthebest 04-02-2007 15:33

Re: why does aux1 doesn't work?
 
do you have aux1 defined in your header file? check to see if it is going to the right place and not into a different file. Recheck your variables and make sure your definitions are what you want them to be.


All times are GMT -5. The time now is 04:15.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi