Page 1 of 1
Posted: Fri Mar 07, 2003 9:17 pm
by BackupUser
Restored from previous forum. Originally posted by Max..
Code: Select all
bIDCmd = (VersionParams.bIDEDeviceMap >> i & 0x10) ? \ IDE_ATAPI_ID : IDE_ID_FUNCTION;
I'm having a hard time with this one. Structure is there, constants defined. >> i & 0x10 _seems_ to be clear (at least it looks like the parts where I used that works) but with "? \ ..." the pain starts...
Anywhere Santa's little helpers around?
Max.
Posted: Fri Mar 07, 2003 9:32 pm
by BackupUser
Restored from previous forum. Originally posted by plouf.
\ means that the line continues to the next line
expresion ? result1 : result2
is an operator which returns result1 if expression is true
otherwise returns result2
hope that helps
Christos
Posted: Fri Mar 07, 2003 9:36 pm
by BackupUser
Restored from previous forum. Originally posted by Max..
Code: Select all
bIDCmd = (VersionParams.bIDEDeviceMap >> i & 0x10) ? IDE_ATAPI_ID : IDE_ID_FUNCTION;
Yes, thanks, helps already.
Found that "? :" are conditional operators. But still I need some digging to understand that... or do you know?
Max.
Edit:
Found this now...
`?:'
The ternary operator. `A ? B : C' can be thought of as: if A
then B else C. A should be of an integral type.
at
http://docs.freebsd.org/info/gdb/gdb.in ... ators.html
Getting closer...
PS: Actually you said that already. Sorry, too tired. :-/
Posted: Sat Mar 08, 2003 12:41 am
by BackupUser
Restored from previous forum. Originally posted by Kale.
This is called a conditional expression and used lots in C++ and hibrids (Javascript, etc...) basically you have an expression to evaluate then 2 statements which are executed weather the expression is true or false. As christos says, it usually like this:
var = (expression to evaluate) ? var is this if true : var is this if false;
and thats it
--Kale
In love with PureBasic! 
Posted: Sat Mar 08, 2003 7:38 am
by BackupUser
Restored from previous forum. Originally posted by plouf.
Found that "? :" are conditional operators. But still I need some digging to understand that... or do you know?
i believe this code is as this PB (but its been some time since i have touch C so ...

)
If (VersionParams\bIDEDeviceMap >> i & 0x10)
bIDCmd = #IDE_ATAPI_ID
Else
bIDCmd = #IDE_ID_FUNCTION
endif
Christos
Posted: Sat Mar 08, 2003 12:35 pm
by BackupUser
Restored from previous forum. Originally posted by Max..
If (VersionParams\bIDEDeviceMap >> i & 0x10)
bIDCmd = #IDE_ATAPI_ID
Else
bIDCmd = #IDE_ID_FUNCTION
endif
Yes, beside changing 0x10 to 16 I used it that way and it seems to do. Sadly I will only really be sure once all is done.
As I said yesterdays, was way too tired to understand your posting in the first run though it contained anything needed. The second run was better; must have been the Vodka that helped.
Max.