Page 1 of 1

Use....

Posted: Mon Feb 13, 2017 2:51 pm
by Josh
I don't understand, why I have to use i.e. UseCRC32Fingerprint() in the following example:

Code: Select all

UseCRC32Fingerprint()
Debug FileFingerprint (FileName$, #PB_Cipher_CRC32)
In the second line I have defined what I want to do and in this case, compiler should know by itself, that he has to use the plugin for CRC32.

The same situation is with the image-plugins. In this case, help even writes that the compiler finds the correct decoder itself. What??? Why do I have to specify something at all? In my opinion, these are all tasks of the compiler and not of the programmer.

Re: Use....

Posted: Mon Feb 13, 2017 3:02 pm
by Fred
UseXXXFingerPrint() register the plugin in the available list (ie: it links the necessary code, so your exe gets bigger). It's not possible for the compiler to solve this easily (you can also use a variable to specify your plugin)

Re: Use....

Posted: Mon Feb 13, 2017 3:19 pm
by nco2k
Fred wrote:you can also use a variable to specify your plugin
exactly. if you use SaveFileRequester() for example and let the user choose the format, you have to know in advance what formats you want to support. the variable could be anything and SaveImage() etc. doesnt know the range of the formats you intend to support, unless you specify it manually (UseXYZ).

c ya,
nco2k

Re: Use....

Posted: Mon Feb 13, 2017 4:29 pm
by Josh
Fred wrote:you can also use a variable to specify your plugin
makes sense, thxs :D

Re: Use....

Posted: Mon Feb 13, 2017 4:58 pm
by TI-994A
Fred wrote:...It's not possible for the compiler to solve this easily...
Just to play devil's advocate, since plugins can be included anywhere in the code, and not necessarily at the top, why couldn't the relevant plugin be automatically included when the corresponding format is encountered?

For example, upon encountering a LoadImage() function with a JPG file, automatically load the UseJPEGImageDecoder plugin? Or when the first FileFingerprint() function is found with the CRC32 flag, automatically load the UseCRC32Fingerprint plugin?

And these could be X-included deals, meaning, subsequent encounters would be ignored.

Re: Use....

Posted: Mon Feb 13, 2017 5:02 pm
by Fred
How to find the format at compile time if the file comes from an OpenFileRequester() ? :)

Re: Use....

Posted: Mon Feb 13, 2017 5:14 pm
by Thunder93
If LoadImage is used dynamically to load various formats after executable is made. We will run into problems. To automatically include these supports at runtime, when we don't even have the need. Our executables be larger, hence why I don't mind adding those functions myself manually when desired.

Re: Use....

Posted: Mon Feb 13, 2017 5:33 pm
by TI-994A
Fred wrote:How to find the format at compile time if the file comes from an OpenFileRequester() ? :)
Great use-case! Thanks for the answer, Fred.