Jump to content
IGNORED

IntyBASIC Conditional Include?


Recommended Posts

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.

 

 

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...