Using the tenary operator in C with 3 numbers - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Utilities (https://qb64phoenix.com/forum/forumdisplay.php?fid=8) +---- Thread: Using the tenary operator in C with 3 numbers (/showthread.php?tid=2916) Pages:
1
2
|
RE: Using the tenary operator in C with 3 numbers - a740g - 09-12-2024 Well, until we get a short-circuiting ternary operator in QB64-PE. Here is my attempt, just for fun. My version brazenly exploits how QB64 uses the C++ compiler. This correctly eliminates the part that doesn't require evaluation. Cheers! Save as iif.h Code: (Select All) #pragma once Code: (Select All)
RE: Using the tenary operator in C with 3 numbers - bplus - 09-12-2024 (08-08-2024, 08:53 PM)Pete Wrote: I look at it as shorthand... Yeah @a740g if that is the Ternary then it's the more familiar (to me at least) IFF as in IFF(expression, ReturnThisTrueValue, ElseReturnThisValue) ServeBeverage$= IFF$(age>=18, "Beer," "Juice") and maybe not so popular in QB64 land because you have to Type the function returns. RE: Using the tenary operator in C with 3 numbers - vince - 09-12-2024 (09-12-2024, 02:17 PM)bplus Wrote: and maybe not so popular in QB64 land because you have to Type the function returns.it would be cool to have _WORD$ in QB64, maybe one that works on numbers too RE: Using the tenary operator in C with 3 numbers - bplus - 09-12-2024 (09-12-2024, 02:37 PM)vince Wrote:(09-12-2024, 02:17 PM)bplus Wrote: and maybe not so popular in QB64 land because you have to Type the function returns.it would be cool to have _WORD$ in QB64, maybe one that works on numbers too You have that from me a long while ago, possibly posted on old forum in toolbox. I called it Item$ and had some other tools to go along with it, all string$ type. I posted it at another forum this year I think. Luke put up fast versions for numbers at the old forum as well. Update: it's here too! https://qb64phoenix.com/forum/showthread.php?tid=2414&pid=22809#pid22809 RE: Using the tenary operator in C with 3 numbers - Jack - 09-12-2024 @bplus Quote: Luke put up fast versions for numbers at the old forum as well.do you have the link for Luke's code ? RE: Using the tenary operator in C with 3 numbers - bplus - 09-12-2024 Reply #94 I think this is a copy of Luke's work and my own follows in next post? https://qb64forum.alephc.xyz/index.php?topic=1511.msg129084#msg129084 The main use of this stuff is using Strings for Arrays in UDTs. RE: Using the tenary operator in C with 3 numbers - Jack - 09-13-2024 thanks bplus |