Code: Alles auswählen
Macro Iif(Expression, TrueValue, FalseValue)
FalseValue + Bool(Expression) * (TrueValue - FalseValue)
EndMacro
Macro IifS(Expression, TrueString, FalseString, Separator = "|")
StringField(FalseString + Separator + TrueString, Bool(Expression) + 1, Separator)
EndMacro
Debug IifS(1 = 1, "Ja", "Nein")
Debug IifS(1 = 0, "Ja", "Nein")
Debug Iif(1 = 1, 11, 55)
Debug Iif(1 = 0, 11, 55)
Hier noch ein Speed-Test:
Code: Alles auswählen
CompilerIf #PB_Compiler_Debugger
CompilerError "Debugger ausschalten!"
CompilerEndIf
; !!!!!!!!! Purifier ebenfalls ausschalten !!!!!!!!!
Macro Iif(Expression, TrueValue, FalseValue)
FalseValue + Bool(Expression) * (TrueValue - FalseValue)
EndMacro
Macro IifS(Expression, TrueString, FalseString, Separator = "|")
StringField(FalseString + Separator + TrueString, Bool(Expression) + 1, Separator)
EndMacro
Define.s Result$
Define.i Result, Time, Time_Result_1, Time_Result_2, i
#Rounds = 100000000
Time = ElapsedMilliseconds()
For i = 1 To #Rounds
Result$ = IifS(1 = 1, "Ja", "Nein")
Result$ = IifS(1 = 0, "Ja", "Nein")
Result = Iif(1 = 1, 11, 22)
Result = Iif(1 = 0, 11, 22)
Next
Time_Result_1 = ElapsedMilliseconds() - Time
Time = ElapsedMilliseconds()
For i = 1 To #Rounds
If 1 = 1 : Result$ = "Ja" : Else : Result$ = "Nein" : EndIf
If 1 = 0 : Result$ = "Ja" : Else : Result$ = "Nein" : EndIf
If 1 = 1 : Result = 11 : Else : Result = 22 : EndIf
If 1 = 0 : Result = 11 : Else : Result = 22 : EndIf
Next
Time_Result_2 = ElapsedMilliseconds() - Time
MessageRequester("", Str(Time_Result_1) + #CRLF$ + Str(Time_Result_2))
Code: Alles auswählen
10931
6439