First Spear Posted March 28, 2018 Share Posted March 28, 2018 I have a procedure in my main .bas program, which includes another .bas file with a same-named Procedure. I'd like to move that same-named external procedure to a 3rd .bas, and only include it in under certain conditions at compile time. Is anyone dealing with a similar situation? Is there a way to conditionally include/exclude Procedures any other way? Thanks. Quote Link to comment Share on other sites More sharing options...
artrag Posted March 28, 2018 Share Posted March 28, 2018 There is no preprocessor nor separate name spaces, so I think you need to rename the procedures to avoid name collisions and include both in your rom Quote Link to comment Share on other sites More sharing options...
+nanochess Posted March 28, 2018 Share Posted March 28, 2018 As ARTRAG says correctly there's no way yet to include files conditionally. The solution would be different main files with different sets of INCLUDE statements. Quote Link to comment Share on other sites More sharing options...
carlsson Posted March 28, 2018 Share Posted March 28, 2018 I suppose one could wrap together your own preprocessor, a batch script that generates the temporary BAS file which the compiler gets to work with. I don't know if it is worth the work, perhaps if you have very complex projects. I was also looking for #ifdef before but realized that IntyBASIC doesn't have such features and perhaps doesn't really need it anyway? Quote Link to comment Share on other sites More sharing options...
First Spear Posted March 29, 2018 Author Share Posted March 29, 2018 I had a kind of preprocessor building .bas files once, stopped messing with it over a year ago, was thinking that there might be a better/smarter way to do it, without needing a "preprocessor". Thanks. I suppose one could wrap together your own preprocessor, a batch script that generates the temporary BAS file which the compiler gets to work with. I don't know if it is worth the work, perhaps if you have very complex projects. I was also looking for #ifdef before but realized that IntyBASIC doesn't have such features and perhaps doesn't really need it anyway? Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted March 31, 2018 Share Posted March 31, 2018 I had a kind of preprocessor building .bas files once, stopped messing with it over a year ago, was thinking that there might be a better/smarter way to do it, without needing a "preprocessor". Thanks. What are the sort of conditions you are looking for? Are their the sort of conditions that would be available to a pre-processor during compilation? You may be able to pass it on to the assembler pre-processor by using assembler conditional directives, though I do not know if this would work (I don't see why not). For example: in "main.bas" ' IntyBASIC source code here... INCLUDE "foobar.bas" ' IntyBASIC source code here... In "foobar.bas": ASM IF (DEFINED FOOBAR = 0) ASM FOOBAR = 1 ' IntyBASIC source code here... ASM ENDI Now if file "fred.bas" happens to include "foobar.bas" as well afterwards, it won't be assembled because the conditional wrapping it will fail. This way you can "include" the file in multiple places, but only have it take effect once. I have no idea if this is the sort of thing you are looking for. Can you provide some example of the conditions you are aiming to test? You should be able to set assembler symbols and have the assembler pre-processor test them in similar ways. -dZ. P.S. Note that this would probably run afoul of the IntyBASIC Programming Contest rules. 1 Quote Link to comment Share on other sites More sharing options...
intvnut Posted April 2, 2018 Share Posted April 2, 2018 One trick I've used with AS1600 is to modulate the "include search path" so that the assembler finds the right version of a file based on how I want to build my executable. That is, in the ASM file, I'd INCLUDE "foo.asm", and outside, I'd change the include path AS1600 would search on, so it'd find different files for the configuration bits. I don't think IntyBASIC has an include search path (with multiple elements, akin to $PATH), but rather just an include directory that consists of a single directory path. So, that may or may not work for you. I guess it depends on the complexity of the condition you're using to select a different file to include. If it's a high-level decision (debug vs. release build), then maybe modulating the library include directory is enough. You might need to copy some library files to both places—or symlink them if you're on Mac or Linux—but if they're effectively read-only otherwise, that's a small price to pay. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.