Code: Select all
If Condition Then Call MySub
Code: Select all
If Condition : MySub() : EndIf
Code: Select all
If Condition Then Call MySub
Code: Select all
If Condition : MySub() : EndIf
The request if implemented only saves the typing of one additional character (or three if formatted according to my preferences).Quin wrote: Mon Feb 17, 2025 4:26 pm The ability to declare a single statement next to an if block like this would be incredibly nice.
Code: Select all
;1234567890123456789012345
If Condition Then MySub()
;12345678901234567890123456
If Condition:MySub():EndIf
;or the way I format it
;1234567890123456789012345678
If Condition: MySub(): EndIf
Me too.Demivec wrote: Mon Feb 17, 2025 9:00 pm I like PureBasic's consistent implementation as separate lines with the option to make compound statements for compactness with ':'.
Code: Select all
If Condition : MySub()
Code: Select all
Macro Do (code)
: code : EndIf
EndMacro
Procedure MySub()
Debug "a=1"
EndProcedure
a=1
If a : Do(MySub())
Likewise, I wasn't suggesting adding the Then keyword to PB, I was simply asking for single-line if statements like thatCaronte3D wrote: Tue Feb 18, 2025 9:53 am I wrote +1 but my idea was more like that (without "then"):Code: Select all
If Condition : MySub()
How do I know where the end of the block is? For the compiler, the code will look like this:Caronte3D wrote: Tue Feb 18, 2025 9:53 am I wrote +1 but my idea was more like that (without "then"):Code: Select all
If Condition : MySub()
Code: Select all
If Condition
MySub()
Code: Select all
if Condition
MySub()
fi
Easy, the compiler would add EndIf after the next statement, just before the newline and only if everything is on the same line.
Code: Select all
If Condition fi MySub()
If (Condition) MySub()
If [Condition] MySub()
If {Condition} MySub()