Charles,
Does O2 have a ternary operator equivalent?
int a = 10, b = 20, c;
c = (a < b) ? a : b;
printf("%d", c);
James
Hi James,
It can be done with macro functions (the C ternary syntax proved to be too messy)
macro iif int(r, e,a,b)
========================
if e
r=a
else
r=b
endif
end macro
'
int a = 10, b = 20
print iif(a < b , a , b)
Good morning,
Charles you example doesn't Work Here Got an Error message in
Print iif(a<b,a,b) ' Not found [a
Here's another example
' o2-tenary-frank c to oxygen
uses console
''
'' int a=10, b=20,c;
'' if(a<b){c=a}
'' else{c=b}
'' printf("%d",c)
Dim a As Integer = 10
Dim b As Integer = 20
Dim c As Integer
If a < b Then
c = a
Else
c = b
End If
Print c 'result 10
wait
It works here. I also tested it with a console:
uses console
macro iif int(r,e,a,b)
========================
if e
r=a
else
r=b
endif
end macro
'
int a = 10, b = 20
print iif(a < b , a , b) cr
wait
Hi Charles your Code is working Well.. Made an Update of oxygen Basic dont know what was the Problem Here