# greater than

## Recommended Posts

can i use the symbols < or > for greater than or less than in DF?

and also, if i set my timing on a channel to 15 seconds, can i use 2 global variables in the same sequence to do 2 different things from the same channel?

like this -

```global drate
global FeetDown = (ch0[0]*-10000*bristolspan+zeroch5)*60 //equation for feet multiplied by the constant
global FeetMins = (ch0.Timing[1]) //not sure if this is correct to read time on the channel

//ch0 timing is set to 15 secs

while(1)
drate = 1
drate = 0
endif
drate =  (FeetDown/FeetMins)
delay(1)
endwhile
```

also, with ValueToAdd, that is a number submitted by the user in a edit box...will the ValueToAdd stay the same until a different number is submitted? how could i make it to where when it gets to zero, drate will be turned off until the next ValueToAdd is submitted?

is the above code even correct?

thanks!

##### Share on other sites

First, and I hate being so picky, but watch your indentation!

Next, yes, you most definitely can use > and < as well as <= and >=. However, you cannot have a space between < and = as it appears you do.

Next, yes, you can use two global variables in a sequence. No problem, but watch for conflict if you copy this code to another channel.

Next, yes, ValuetoAdd will stay the same, provided you don't have something changing it somewhere else. Note that you'll need to declare and initialize the variable somewhere else (an auto-start sequence usually)

Next, I don't know what you mean by drate being turned off. I also don't get your logic, since the if() statement sets drate to 0 or 1, and then immediately after that you set it to an expression.

1) I'd probably put this in the Ch1's channel event. You could do it in a separate sequence like you did with a while() loop, but its not that efficient. If you put it in the event, get rid of the while() loop and the delay(1)

2) As is, it won't work properly because you are calcing feetdown and feetmins outside the loop, so they'll only get calced once.

3) your feetMins calc is wrong. To get the current system time of ch0 you want: ch0.time[0]. To get the Timing parameter of the channel, you want Ch1.Timing like you have it, but without the [1]. Ch1.Timing isn't an array so doesn't need the [].

4) In your if() you can't put a space between = and <

5) The else doesn't take an expression. Its just the opposite of the if(). Else should always be on its own line with nothing else (except maybe comments)

##### Share on other sites

Awesome, and as always, thank you.

Did this clean it up a little? -

```global drate
global FeetDown = (ch0[0]*-10000*bristolspan+zeroch5)*60
global FeetMins = (ch0.Timing)

while(1)
drate = (FeetDown/FeetMins)
else
drate = 0
endif
delay(1)
endwhile
```

by having the ch0 timing set to 15 seconds, will that give me what happened between the 2 readings, or just the value every 15 seconds?

Thanks again!

##### Share on other sites

That's a start, but you still missed a couple points:

1) you forgot to properly indent

2) your calcs of feetdown and feetmins are outside the loop, so won't update.

I think what you want is:

```global drate
global FeetDown
global FeetMins

while(1)
FeetDown = (ch0[0]*-10000*bristolspan+zeroch5)*60
FeetMins = (ch0.Timing)
drate = (FeetDown/FeetMins)
else
drate = 0
endif
delay(1)
endwhile
```

##### Share on other sites

thanks for sqaring up my code

i just thought of this - could this be correct?

```global drate
global FeetDown
global FeetMins

while(1)
FeetDown = ((ch0[0]*-10000*bristolspan+zeroch5)-(ch0[1]*-10000*bristolspan+zeroch5))*60
FeetMins = ((ch0[0].Time)-(ch0[1].Time))
drate = (FeetDown/FeetMins)
else
drate = 0
endif
delay(1)
endwhile
```

Thank you and have a good one!

##### Share on other sites

Yes, that looks almost right, except the [] goes after "Time". Also note that FeetMins will be in seconds. Two other minor things:

1) Some basic algebra will clean up the FeetDown calc:

((ch0[0] - ch0[1]) * -10000 * bristolspan + zeroch5) * 60

Some spaces also make it more readable.

2) You don't need all those extra () in the FeetMins calc, just:

FeetMins = ch0.Time[0]-ch0.Time[1]