IncludeFile Idea

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by blueb.

While I can use the IncludeFile function in my programs to avoid cutting and pasting, it makes my programs a lot larger than they could be.

If I need only one function (say: GetDriveSpace), then I have two choices:
#1 - Copy the routine to the clipboard and paste it into my program
#2 - use IncludeFile "Utilities.pb" in my program (where GetDriveSpace) is located.
------------------------------------------------------------

To keep PureBasic programs as small as possible, I think PB might explore the following:

#1 - Read the user's file and find all the "IncludeFile" functions
#2 - Create a temporary Include.pb file in the program's directory.
#3 - Paste ONLY the functions used in the programmers code file
#4 - Compile the user's code using the temporary Include.pb file

The result would be smaller PB programs.
-------------------------------------------------------------

For example, I created a program:

Code: Select all

IncludeFile "C:\PureBasic\Util.pb"
MessageRequester("","Hello World",0)
End
If I don't include the first line.... EXE size = 5k
with first line...................... EXE size = 39k

Big difference, and I have a "small" Include file.

Regards,
--blueb
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Hitman.

I remember Delphi has such "smart compiling" technology, but it need a lot work to do.
(But even Delphi isn't that smart, it still make BIG exes)

Before Fred sorted it out, I just copy and paste what I need to a new include file.

Well, everyone needs to do something for living.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

It sounds like a cool Editor add-on tool.
1. Search the code for used 'Procedure Names'.
2. Compare the names with the 'Procedure Names' provided in YOUR BIG INCLUDE FILE.
3. Generate new 'Include File' for this special project in the project directory.


Have a nice day...

Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by horst.

How about a "small solution" using CompilerIF
Example:

#mod = #true
IncludeFile "include\misc.pbi"

Problem is: I would have to set all switches to #false
for the procedures I don't want, because PB would report
errors otherwise.

I suggest that the directive

CompilerIF #constant

should be FALSE if the #constant is NOT defined
(and not report any error).

This should not be too difficult. Fred??



Horst
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Num3.
Originally posted by Franco

It sounds like a cool Editor add-on tool.
1. Search the code for used 'Procedure Names'.
2. Compare the names with the 'Procedure Names' provided in YOUR BIG INCLUDE FILE.
3. Generate new 'Include File' for this special project in the project directory.


Have a nice day...

Franco

I agree, this sounds like a good idea. Fred's got more to concern about, and it would be a nice addon to the Editor.


--
Kind Regards

Rui Carvalho
[DURON 1K - 256Mb - 40Gb - GFORCE MX2 64Mb - W2K PRO]
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

I will probably add this feature in a future version of PB. Just need a bit compiler rewrite, so I will wait a bit.

Fred - AlphaSND
Post Reply