Code: Select all
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
If SizeOf(Character) = 1
CompilerElse
If SizeOf(Character) = 2
CompilerElseIf
EndIf
Code: Select all
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
If SizeOf(Character) = 1
CompilerElse
If SizeOf(Character) = 2
CompilerElseIf
EndIf
I do not know if your are just trying to show a simple example or not, but what you have is much better to be changed so you have constant assignment values in the conditional compilation, so the IF statement is the same line regardless of any conditional compilation. For instance:fryquez wrote:The IDE's Format Indentation doesn't work well with CompilerIf and If statements
Same Problem for Import/EndImportCode: Select all
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86 If SizeOf(Character) = 1 CompilerElse If SizeOf(Character) = 2 CompilerElseIf EndIf
Code: Select all
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
#Value = 1
CompilerElse
#Value = 2
CompilerEndif
If SizeOf(Character) = #Value
Endif
Code: Select all
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
**If SizeOf(Character) = 1
**CompilerElse
****If SizeOf(Character) = 2
****CompilerElseIf
****EndIf
Code: Select all
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
**If SizeOf(Character) = 1
CompilerElse
**If SizeOf(Character) = 2
CompilerElseIf
...
Wait... if the editor can correctly format If/Else/EndIf, then why can't it also do it for CompilerIf/CompilerElse/CompilerEndIf? There's literally zero difference except for the keywords. I don't get it.Tenaja wrote:You are basically asking the IDE to compile code
Speaking from experience, it is not too difficult to indent after every IF, and unindent at every EndIf.Thunder93 wrote:Doesn't matter what code is used from CompilerIf.
If CompilerIf started 7 spaces over, the other Compiler* entries should also follow that rule. Therefore the other Compiler* entries should also be 7 spaces over. The following Compiler* entries should not be influenced by what has been placed in side the CompilerIf block.
If PB IDE is only going by what was on the previous line, then maybe some more thought should be put into this PB Indentation system.
But why? That's why I don't get. Assuming "indent" is a variable that keeps track and starts at 0:Tenaja wrote:It is exponentially more difficult to have conditional indentation.
Currently the IDE only has to look at the line before to see if the indent needs to be increased or decreased.Dude wrote:But why? That's why I don't get. Assuming "indent" is a variable that keeps track and starts at 0:Tenaja wrote:It is exponentially more difficult to have conditional indentation.
See a line with CompilerIf: "indent+2", which is applied to all following lines.
See a line with CompilerElse: use "indent-2" for this line only, so no indent occurs.
See a line with CompilerEndIf: "indent-2", which is applied to all following lines.
What's the big deal? I could write a pre-processor in 10 seconds to do this.
It is relatively easy to create a text formatter that only looks at existing text.Dude wrote:But why? That's why I don't get. Assuming "indent" is a variable that keeps track and starts at 0:Tenaja wrote:It is exponentially more difficult to have conditional indentation.
See a line with CompilerIf: "indent+2", which is applied to all following lines.
See a line with CompilerElse: use "indent-2" for this line only, so no indent occurs.
See a line with CompilerEndIf: "indent-2", which is applied to all following lines.
What's the big deal? I could write a pre-processor in 10 seconds to do this.
Btw, I don't see whats wrong with putting a ";<" marker behind the IF line to correct the auto-indent in special cases like this. That is why the possibility to use such markers exist.Here is my suggestion: If somebody can define a good algorithm (in words, not code) how to handle the indentation of comments, i will try to implement it.
These are the conditions under which the indentation code must operate:Good ideas are welcome
- The IDE must decide based on the content of the previous line how to indent the next one.
- It can scan a little further back (past an empty line or comment for example) to get more context, but the look-back must be short. I.e. the ident algorith cannot start from the beginning of the source. It must work with only limited context information around the current line.
Code: Select all
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
If SizeOf(Character) = 1 ;<
CompilerElseIf #PB_Compiler_Processor = #PB_Processor_x64 ;<
If SizeOf(Character) = 2 ;<
CompilerElse
If SizeOf(Character) = 4 ;<
CompilerEndIf