[Implemented] CompilerIfDef #const

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

[Implemented] CompilerIfDef #const

Post by BackupUser »

Restored from previous forum. Originally posted by GPI.

If the #const is definied, the compiler should translate this line.

Why?

For example this:

main.pb

Code: Select all

  #MainStart=1
  xincludefile "help.pbi"
  ....
help.pbi

Code: Select all

  CompilerIfDef #MainStart
    ...
  CompilerElse
    XIncludeFile "main.pb"
  CompilerEndIf
So, when i try to compile the help.pbi, automatic the main.pb will compiled.

(Implemented with 'Defined()')

PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

What is "CompilerIfDef" ? That's not a PureBasic command.

The following code works fine, and seems to be what you want?

Code: Select all

#test=1
CompilerIf #test
  Debug "test=1"
CompilerElse
  Debug "test1"
CompilerEndIf
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by plouf.

i think gdi means CompilerifDef(ined)
so if he trys to compile/run help.pbi
it will first check if #MainStart is allready defined
if it is it means that he tries to compile throught main.pb
so it will not reinclude main.pb if it is not it means it tries to compile throught help.pbi and includes main.pb in top



Christos
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by GPI.

@plouf
GPI!
(thats funny, this forum is the only forum i know, who write my name false. It happen two times...)

@PB
try this:
compilerif #test
debug "test"
compilerendif

The compiler say then, that #test is not defined.
if want to check, if a constant is defined or not.

Create the two files of the example in my first posting and compile help.pbi


PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> if want to check, if a constant is defined or not.

Oh, I see. I think Fred said that is coming...?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

Why not.. I take good note.

Fred - AlphaSND
Post Reply