Integratable Version Of PreProcessor Released
Community Forums/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! |
| ||
Oh, and the source was not included with this release. That is because Option Explicit, Code Profiling and Inline Functions are not implemented yet. |
| ||
Oh yes, yes, very nice, very nice.. ;) |
| ||
Can't get past: Blitz Preprocessor Config File NOT Found! Any ideas? blitzpath is set correctly, blitzcc.exe renamed to blitzccbackup.exe, and preprocessorconfig directory is in bin directory. I am using Ultraedit, not BlitzIDE, but should work the same. Thanks, MK |
| ||
Forgive my ignorance, but what is a preprocessor? |
| ||
It's a program that takes your source files as input, does some processing on it and outputs the processed sources. Then theese modified sources are compiled the normal way. The processor Michael Reitzenstein has done is working pretty much like the one that ships with C compilers: it allows to add special statement (the ones that start with a '#') that are understood by the preprocessor. For example you can make code that will be compiled only if a certain macro is defined (say DEBUG): #IfDef DEBUG blabla #EndIf Then "blabla" will stay in the final( preprocessed) source only if 'DEBUG' is defined. It's very useful to add consistency testes that makes debugging much easier, while letting you suppress these checks (which involves an ovehead by theirselves) when you are sure all works fine: you only need to undefine DEBUG for this. You may want to just type something like "C preprocessor" in any search engine to find more info. |
| ||
makakoman - try copying the configuration directory to ultraeditdir/bin/whateverthehellicalledtheconfigdir and see if that makes any difference. The preprocessor assumes it starts off relative to IDE.exe currently, and to get around this I just need to tap into that blitzpath stuff :) |
| ||
Copying to the ultraedit executable directory didn't seem to fix the problem. Thanks for the suggestion. Regards, MK |
| ||
Hmm... I will have a look at this later on. I have only attempted integration with the Blitz IDE so far (since that is what the majority of Blitz users use) but obviously support for other editors such as UltraEdit will have to come soon. |
| ||
"4) Run Blitz3D or BlitzPlus. " Was this an accidental omission or should Blitz2D users stop reading now? |
| ||
Was that a healthy suggestion or a rant? ;) |
| ||
Uh no, actually I'd been following this with some interest and whilst I didn't have access to download it and test I thought I'd ask if there was something about it that meant it could no longer work with Blitz2D. Given the near-identical non-3D coding of 2D and 3D (userlibs being the BIG difference), I thought I'd better check. Now if it was a rant, I'd still be going. ;o) |
| ||
i get the error, "Runtime Error! C:\Program Files\Blitz3D\bin\ide.exe abnormal program termination" i really want to use this to please help im using b3d |
| ||
Line - the preprocessor will work completely fine in Blitz Basic. SSS - Is your blitzpath environment variable set? Shane Monroe wrote an excellent piece on using Blitz with Ultra Edit and his environment variables setup tutorial is basically what you will need to do to get this working: |
| ||
It seems that you do not need an environment variable to use this preprocessor with the IDE. I fired up a third party IDE and I am trying to get it working right now. |
| ||
It now works with a third party IDE, as long as you set environment variables... Patch Taken Down - Newer version released |
| ||
Michael, Thanks for addressing the third party IDE feature. Unfortunately, the application crashed with: Unhandled Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array. at Types.Add_Type_Line(String Type_Line, Type Current_Type) at Source_Collection.Add_Line(String Line, Source_File Originating_File, Int32 Originating_Line) at Source_Collection.Read_Source_File(String Path) at Source_Collection.Add_Line(String Line, Source_File Originating_File, Int32 Originating_Line) at Source_Collection.Read_Source_File(String Path) at Source_Collection.Add_Line(String Line, Source_File Originating_File, Int32 Originating_Line) at Source_Collection.Read_Source_File(String Path) at Source_Collection.Add_Line(String Line, Source_File Originating_File, Int32 Originating_Line) at Source_Collection.Read_Source_File(String Path) at Program_Entry.Main(String[] Arguments) Thanks, MK |
| ||
OK thanks for the bug report. Any chance of any code that reproduces this error? It should be the single type declaration that does this, and with any chance it is just a simple error on my part that will be easily fixed. |
| ||
Function Profiling is now in. It uses much the same technique as the original and was quite easy to add, but that means it is still contained in the same old ugly HTML style stuff :) |
| ||
New version released. Mostly new is #Profile, which generates a profile of your code. |
| ||
Option Explicit release tomorrow... |
| ||
Option Explicit ??? YYYYYYYYYAAAAAAAAAAAAAAAAAAAAHHHHHHHHHOOOOOOOOOOOOOOOOO !!! :) |
| ||
Cool =D Sorry to nag, but any idea of when you'll be releasing the source? I'm fascinated as to how you implemented code profiling (amongst other things) =) Top work =) |
| ||
Source shall be released with release version 1.0, with all features. If I decide to implement inline functions (which I may not because Macros are probably cleaner/more useful IMHO) I will do that before releasing the source, and if not I will release the source with the Option Explicit version. The source will be released under a GPL, possibly LGPL. Hopefully community effort can make this preprocessor rock solid and viable to use in large projects without fear of bugs or shortcomings. Some people have managed to crash it however I believe that anything that does crash it is a small oversight on my behalf and easily fixed once spotted. Speaking of which - if you manage to crash this - please, please, please, please provide me with source that will crash it (or provide an oddity). The bug will be fixed and the preprocessor will benefit greatly! |
| ||
Have you added enumeration ? for those that don't know, enumeration is; enum { GOD, JESUS, WIFE, APPLE, FOOD, FOO } where the constants = GOD=0 JESUS=1 WIFE=2 APPLE=3 FOOD=4 FOO=5 Cool tool btw, keep up the work :) |
| ||
I was thinking:Switch Something {Yes,No,Maybe,Possibly} Global Switch Blah = Yes Blah = No Blah = Asdf;Trips an error But honestly - if you want it, you can add it! |
| ||
Bleh, Option Explicit bug with constants found (eg $FF). Fixing it now. |
| ||
Fixed, but I still have to clean up the mess fixing it caused! |
| ||
Nice news... Please keep on !!! :) Sergio. |
| ||
Has the same problem as SSS, Im using standard IDE, with the environment variable set. What to do?? |
| ||
Did you follow the installation instructions and did you run Blitz IDE directly? I can't actually see how that could happen! |
| ||
Option Explicit version released!. I am going to need a lot of help hunting down the bugs in this release, though. All the major source on this PC compiles perfectly but you never know. Name in the credits for each reported bug! |
| ||
I (or more correctly Beaker) has found a bug in single line if statement parsing. |