Wrong folding with CompilerIf in Procedure declaration

Working on new editor enhancements?
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Wrong folding with CompilerIf in Procedure declaration

Post by Shardik »

Image
User avatar
Bisonte
Addict
Addict
Posts: 1226
Joined: Tue Oct 09, 2007 2:15 am

Re: Wrong folding with CompilerIf in Procedure declaration

Post by Bisonte »

Thats normal. You have two Procedure Keywords and only one EndProcedure....
Add a ;} after EndProcedure and all is ok ...

Image
PureBasic 6.04 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Wrong folding with CompilerIf in Procedure declaration

Post by Shardik »

Thank you for posting your workaround! :)
User avatar
Crusiatus Black
Enthusiast
Enthusiast
Posts: 389
Joined: Mon May 12, 2008 1:25 pm
Location: The Netherlands
Contact:

Re: Wrong folding with CompilerIf in Procedure declaration

Post by Crusiatus Black »

I usually use a method where a Macro contains the body and I simply define the procedure twice.

Code: Select all

Macro ProcedureName_Body()
  If((a + b) % 2 = 0)
    Debug "Sum is even!"
  Else
    Debug "Sum isn't even! :("
  EndIf 
EndMacro

CompilerIf #PB_Compiler_OS = #PB_OS_Windows
  Procedure ProcedureName(a.i, b.i)
    ProcedureName_Body()
  EndProcedure
CompilerElse
  ProcedureC ProcedureName(a.i, b.i)
    ProcedureName_Body()
  EndProcedure
CompilerEndIf

ProcedureName(10, 3)
Image
Bas Groothedde,
Imagine Programming

I live in a philosophical paradoxal randome filled with enigma's!
Post Reply