Detect whether PB 5.70 DPi flag is checked

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Blue
Addict
Addict
Posts: 864
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: Detect whether PB 5.70 DPi flag is checked

Post by Blue »

Message to Fred :
Fred wrote:Just forgotten. Moved to feature request.
So, have you remembered to add the promised constant to PB 5.72 ?
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
User avatar
Blue
Addict
Addict
Posts: 864
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Re: Detect whether PB 5.70 DPi flag is checked

Post by Blue »

Since PB 5.73 has just been released with still no sign of the promised constant, here is a modified version of the Assembly language code to test whether the DPi_aware option is checked.
I came to this solution after reading carefully (and finally understanding...) the inline assembler entry of the Help file. It really does not get much simpler than the following single Assembly language command :

Code: Select all

EnableASM
Procedure.i DPi_option_checked()
  MOV eax, dword [PB_Compiler_DPIAware] 
  ProcedureReturn
EndProcedure
DisableASM

If DPi_option_checked()
  ; do this and that
EndIf

Debug "DPi_option_checked() ? " + DPi_option_checked()
I kept the PB ASM commands pair outside the procedure only for the sake of greater clarity. It would, of course, make better sense inside the procedure.
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
Post Reply