Integratable Version Of PreProcessor Released

Miscellaneous Forums/Blitz Showcase/Integratable Version Of PreProcessor Released

The Unofficial BlitzBasic Preprocessor is now written entirely in C#, and will integate perfectly into the standard Blitz IDE, as shown. This program compiles and runs perfectly:



Download Here, however READ THESE INSTRUCTIONS FIRST:

1) Rename BlitzCC.exe BlitzCCBackup.exe [name is important as it is called by the preprocessor].

2) Unzip zip into the Blitz Folder\Bin\ directory. BlitzCC.exe (the cunningly disguised preprocessor) should be directly in the Bin folder and there should be another folder 'preprocessorconfig' off the bin folder.

3) Set environment variables up. If you do not know how to do this, you can do it temporarily by entering this into a DOS prompt:

set blitzpath=c:\program files\blitz3d\


4) Run Blitz3D or BlitzPlus.

And here is an example of everything it can do:

;Auto Defined Stuff...
#IfDef DEBUG
	
	RuntimeError "For some stupid reason this program may not be run in debug mode"
	
#Else
	
	#IfDef CREATINGEXE
		
		RuntimeError "Nooooo I don't think so - no EXEs shall run!!"
		
	#Else
		
		#IfDef COMPILEONLY
			
			This Code Will Trip An Error - But Only With Check Errors (F7)
			
		#EndIf
		
	#EndIf

#EndIf

;User Defined Stuff.
#IfNDef My_Define

	#Define My_Define "You Can Even Print With Defines"
	#Define Another_Define Defines Also Work In Strings 
	
	Print My_Define
	Print "Another_Define"
	
#EndIf

#IfNDef My_Define
	
	RuntimeError "This PreProcessor Does Not Work!?"
	
#Else

	Print "All Is Well!"
	
#EndIf

#DefMacro User_Defined_Macro
	
	#IfMacroArg 5
	
		RuntimeError "What are you doing supplying FIVE arguments!?"
		
	#ElseMacroArg
		
		#IfMacroArg 3
		
			Call_A_Function( Arg1, Arg2, Arg3 )
			
		#ElseMacroArg
			
			#IfMacroArg 2
				
				Call_A_Function( Arg1, Arg2, "A Constant" )
			
			#ElseMacroArg
				
				#IfMacroArg 1
				
					Call_A_Function( Arg1, "A Constant", "A Constant" )
					
				#ElseMacroArg
					
					Call_A_Function( "A Constant", "A Constant", "A Constant" )
					
				#EndIfMacroArg
				
			#EndIfMacroArg			
		
		#EndIfMacroArg
		
	#EndIfMacroArg
	
#EndDefMacro

#Macro User_Defined_Macro, "Not A Constant"
#Macro User_Defined_Macro, "Not A Constant", "Not A Constant"
#Macro User_Defined_Macro, "Not A Constant", "Not A Constant", "Not A Constant"

#Define User_Defined_Type This_Will_Replace_All_Instances_Of_User_Defined_Type
#Define Count Now_This_Will_Replace_Count

#Define ASC_A 97
#Define ASC_Z 122
#Define UserInteger 1337
#Define UserPi 3.1415
#Define UserString "Everybody Down!"

Type User_Defined_Type
	
	Field SingleInteger%
	Field SingleFloat#
	Field SingleString$
	
	Field IntegerArray [ 64  ]
	Field FloatArray#  [ 128 ]
	Field StringArray$ [ 256 ]
	
End Type

Global Instance_One.User_Defined_Type = New User_Defined_Type
Global Instance_Two.User_Defined_Type = New User_Defined_Type

Instance_One\SingleInteger = UserInteger
Instance_One\SingleFloat# = UserPi
Instance_One\SingleString$ = UserString

For Count = 0 To 64

	Instance_One\IntegerArray[ Count ] = Rand( 0, 65535 )
	
Next

For Count = 0 To 128
	
	Instance_One\FloatArray[ Count ] = Rnd( UserPi, UserPi * 2.0 )
	
Next

For Count = 0 To 256
	
	Instance_One\StringArray[ Count ] = String( Asc( Rand( ASC_A, ASC_Z ) ), Rand( 5 ) )
	
Next

#SizeOf User_Defined_Type, Instance_One, Bank_Size

Bank_Handle = CreateBank( Bank_Size )
Bank_Handle_Two = CreateBank( Bank_Size )

File_Handle = WriteFile( "test.file" )

#WriteType User_Defined_Type, Instance_One, File_Handle

CloseFile File_Handle
File_Handle = ReadFile( "test.file" )

#ReadType User_Defined_Type, Instance_Two, File_Handle

#PokeType User_Defined_Type, Instance_One, Bank_Handle, 0
#PokeType User_Defined_Type, Instance_Two, Bank_Handle_Two, 0

RuntimeError "And Are The Banks The Same? " + CompareBanks( Bank_Handle, Bank_Handle_Two )

WaitKey( )

Function Call_A_Function( Argument1$, Argument2$, Argument3$ )
	
	Print Argument1$ + "," + Argument2$ + "," + Argument3$
	
End Function

Function CompareBanks( Bank_Handle, Bank_Handle_Two )

	If BankSize( Bank_Handle ) <> BankSize( Bank_Handle_Two )
		
		Return False
		
	EndIf
	
	For Count = 0 To BankSize( Bank_Handle ) - 1
	
		If PeekByte( Bank_Handle, Count ) <> PeekByte( Bank_Handle_Two, Count )
		
			Return False
			
		EndIf
		
	Next 
	
	Return True
	
End Function


Enjoy!