Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Digital Inputs? (http://www.chiefdelphi.com/forums/showthread.php?t=73947)

Straberrie 08-02-2009 19:57

Digital Inputs?
 
Hello!

I am using C++ and I have a question about implementing Digital Inputs in the code... Is Get() the function that means "true" or no? I basically want an if statement saying if DigitalInput1 is true, then this, but I am unsure which function to use to set the condition... =(

Thank you!!! :P

byteit101 08-02-2009 20:32

Re: Digital Inputs?
 
DigitalInput DigtalInput1(1);//port1
if (DigialInput.Get())
{
do this
}
else
{
do that
}

Straberrie 09-02-2009 20:07

Re: Digital Inputs?
 
Thank you!!!!!! :] :]

programMORT11 14-02-2009 23:27

Re: Digital Inputs?
 
how would you do this in C without adding the C++ digitalinput objects? could you cast the UINT32 GetDigitalInput() function results to boolean?

Redneck 15-02-2009 01:47

Re: Digital Inputs?
 
Quote:

Originally Posted by programMORT11 (Post 820963)
how would you do this in C without adding the C++ digitalinput objects? could you cast the UINT32 GetDigitalInput() function results to boolean?

I don't believe so, because C doesn't have a bool data type. Traditionally boolean logic is done in C with integers with 0 for false and 1 for true. It'll still work the same way. If you have
Code:

if(GetDigitalInput()){
    // something
}

it'll work the same way as the C++ bool value.


All times are GMT -5. The time now is 02:28.

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