Use....

Everything else that doesn't fall into one of the other PB categories.
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Use....

Post 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.
sorry for my bad english
Fred
Administrator
Administrator
Posts: 16681
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Use....

Post 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)
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: Use....

Post 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
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Use....

Post by Josh »

Fred wrote:you can also use a variable to specify your plugin
makes sense, thxs :D
sorry for my bad english
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Use....

Post 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.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Fred
Administrator
Administrator
Posts: 16681
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Use....

Post by Fred »

How to find the format at compile time if the file comes from an OpenFileRequester() ? :)
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: Use....

Post 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.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Use....

Post 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.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Post Reply