User module selection

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

Post Reply
gramo
Registered User
Registered User
Posts: 200
Joined: Tue Mar 20, 2007 6:55 am
Location: Australia
Contact:

User module selection

Post by gramo » Sun Aug 14, 2011 9:00 am

David Barker wrote:The compiler will recursively search any folder in the the 'UserLibrary' and use the first module that matches the required include - powerful, but you cannot control which module is found first...
Will a module in the "UserLibrary" parent folder always take precedence to sub folders. For example;

UserLibrary\test.bas
UserLibrary\Sub Folder\test.bas

A quick test suggests it would..
digital-diy.com - Hobby microcontroller projects and tutorials. Assembly, PICBasic and C examples.

Australian distributor for the Swordfish Compiler

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Sun Aug 14, 2011 9:22 am

It depends on what the OS decides to give to the compiler first - file or folder. In short, you cannot guarantee any particular order.

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Post by Jerry Messina » Sun Aug 14, 2011 5:33 pm

Graham,

One thing you CAN do (and I don't know if this helps with what you're trying to do) is to include the subdirectory name in the 'include' statement.

If you have:
UserLibrary\test.bas
UserLibrary\Sub Folder\test.bas

then in your .bas file you can use the syntax:
include "Sub Folder/test.bas"

and SF will find it. Note that you need to use a forward slash, and not a backslash.

This "trick" works because Windows interprets either as a path delimiter, and it seems that SF just passes it along, whereas a backslash doesn't work.

I don't know if this runs afoul of Dave's warning or not.

gramo
Registered User
Registered User
Posts: 200
Joined: Tue Mar 20, 2007 6:55 am
Location: Australia
Contact:

Post by gramo » Mon Aug 15, 2011 1:04 am

Cheers guys. I've had a couple of trial runs with your idea Jerry, things appear to work the way I'd like them to.
digital-diy.com - Hobby microcontroller projects and tutorials. Assembly, PICBasic and C examples.

Australian distributor for the Swordfish Compiler

Post Reply