Got an idea for enhancing PureBasic? New command(s) you'd like to see?
bds107
New User
Posts: 7 Joined: Fri Jul 28, 2023 10:35 am
Location: Bruges (Belgium)
Post
by bds107 » Thu Jul 24, 2025 9:50 pm
Hi everyone!
Back when animals still spoke, there was something called IIF. Unfortunately, it wasn't built into PureBASIC, or I'd have to cross my eyes.
Code: Select all
GLOBAL result.s, userInput.a
result.s = IIF(userInput MOD 2 = 0, "Even", "Odd")
DEBUG "The number is " + result
Hopefully...
Quin
Addict
Posts: 1122 Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:
Post
by Quin » Thu Jul 24, 2025 10:36 pm
This has been requested many times. I've concluded that it'll never happen.
PB isn't a bad language for pounding out a native executable that works across operating systems. But if you want anything even close to modern syntax, it's not it. I personally recommend Crystal for that.
AZJIO
Addict
Posts: 2141 Joined: Sun May 14, 2017 1:48 am
Post
by AZJIO » Thu Jul 24, 2025 10:54 pm
PureAutoIt
Code: Select all
Macro IIf(expr, truepart, falsepart=__expr_null__.b)
If expr
truepart
Else
falsepart
EndIf
EndMacro
bds107 wrote: Thu Jul 24, 2025 9:50 pm
Code: Select all
result.s = IIF(userInput MOD 2 = 0, "Even", "Odd")
Quin
Addict
Posts: 1122 Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:
Post
by Quin » Thu Jul 24, 2025 11:01 pm
AZJIO wrote: Thu Jul 24, 2025 10:54 pm
PureAutoIt
Code: Select all
Macro IIf(expr, truepart, falsepart=__expr_null__.b)
If expr
truepart
Else
falsepart
EndIf
EndMacro
Only works in super basic cases. I can't do this for example:
Code: Select all
MessageRequester("Current score is", Str(Points) + " " + Iif(Points = 1, "point", "points"))
That's why I'd like it to be a language feature, not a new function. But we know how Fred feels about those.
AZJIO
Addict
Posts: 2141 Joined: Sun May 14, 2017 1:48 am
Post
by AZJIO » Thu Jul 24, 2025 11:07 pm
Code: Select all
Procedure.s IIF(expr, truepart.s, falsepart.s)
If expr
ProcedureReturn truepart
Else
ProcedureReturn falsepart
EndIf
EndProcedure
Global result.s, userInput.a = 1
result.s = IIF(userInput & 1, "Odd", "Even")
Debug "The number is " + result
Global Points = 1
MessageRequester("Current score is", Str(Points) + " " + Iif(Bool(Points = 1), "point", "points"))