A bug in the Content plugin api ?

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

titanium
Junior Member
Junior Member
Posts: 51
Joined: 2003-11-07, 10:37 UTC
Location: Israel

A bug in the Content plugin api ?

Post by *titanium »

Hi

I'm trying to program a content plug-in and I think I have found a bug in the TC api. Maybe some of the plugin programmers have noticed it too.

The function ContentGetValue can return a ft_numeric_floating value in FieldValue variable. However if the value is higher than 9 it is rounded up to the nearest integer., example: 22.5->23 , 17.15->18 etc. This does not happen with smaller numbers 9.5 ->9.5. I'm programming in C and the variable I'm copying to the FieldValue is of type double.

The problem occurs only when displaying the number on-screen. Internally TC keeps the correct value.

I tried everything but I could not convince TC to display the numbers properly.

Could this be a bug in the TC api ?
Last edited by titanium on 2005-01-26, 09:50 UTC, edited 1 time in total.
User avatar
Lefteous
Power Member
Power Member
Posts: 9535
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2titanium
It's not a bug. It's by design. The designers aim was to have an equal number of significant digits in all cases.
titanium
Junior Member
Junior Member
Posts: 51
Joined: 2003-11-07, 10:37 UTC
Location: Israel

Post by *titanium »

Lefteous wrote:The designers aim was to have an equal number of significant digits in all cases.
If this is by design, why does the design allows only one digit after the dot ?

It is reasonable to limit the number of digits after the dot to 4 or 5, but it's not reasonable not to display them at all if the number is 10 or higher. Why to include a double precision option in the first place ?

I sure hope this is a bug that will be fixed in the next version.

Maybe Christian has something to say about this ? :roll:
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

why does the design allows only one digit after the dot ?
0.25 works.

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
titanium
Junior Member
Junior Member
Posts: 51
Joined: 2003-11-07, 10:37 UTC
Location: Israel

Post by *titanium »

Hacker wrote: 0.25 works.
It seems that the rule is: if number<1 then 2 significant digits; if 1<=number<10 then 1 significant digit; if number>=10 then no significant digits :(
Last edited by titanium on 2005-01-26, 13:05 UTC, edited 1 time in total.
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Post by *Hacker »

Yes. Two significant digits.

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

I'm open to suggestions on how this could be improved.
Author of Total Commander
https://www.ghisler.com
VadiMGP
Power Member
Power Member
Posts: 672
Joined: 2003-04-05, 12:11 UTC
Location: Israel

Post by *VadiMGP »

I suggest always show floating values with some digits after decimal point. But let to user option to define exact number of digits for the field via extended syntax in the configuration dialog like
<plugin_name>.<field_name>.<total_number_of_digit>.<number_of_digits_after_dec_point>
For example - [media].FPS.4.2
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

The problem is that such syntax would be incompatible with the pluginname.variable.UNIT syntax...
Author of Total Commander
https://www.ghisler.com
titanium
Junior Member
Junior Member
Posts: 51
Joined: 2003-11-07, 10:37 UTC
Location: Israel

Post by *titanium »

I think two significant digit should always be displayed no matter how long the number is. The only exception will be when the digits are zeros.

So 174.3973 will be displayed as 174.39, 245.10111 will be displyed as 245.1 and 322.00122 will be displayed as 322.

I think this is a reasonable suggestion that will not change the way the plugin works and will not clutter the display.

What do you think Christian :?:
VadiMGP
Power Member
Power Member
Posts: 672
Joined: 2003-04-05, 12:11 UTC
Location: Israel

Post by *VadiMGP »

2ghisler(Author)
Syntax isn't a problem. I use it for illustration only. You can add formatting option in tens ways.
I.e
plugin.variable[.unit][.#formatter]
plugin.variable[.unit][.(formatter)]
J.Bl
Member
Member
Posts: 116
Joined: 2005-01-23, 16:29 UTC

I have to come back to this thread

Post by *J.Bl »

Hello,

Excuse me please, I do not want do disturb... but I have to come back to this "ft_numeric_floating values".

At first, I know, "it's not a bug, it's a feature" (see PS:). But... this feature is not the suitable solution in some cases in content plugins. The truth is, I do not unterstand, why this feature is - let me say it in this way - implemented in this manner... The designers had to think on it, that they do not know in all cases, how many digits are suitable or necessary in a colum of a content plugin for users convenience.

So a solution is requested. To make this solution easy to implement and compatible with everything, my suggestion is to add some new Field values to the content plugin API in the next release: ft_numeric_floating_3significantdigits, ft_numeric_floating_4significantdigits, ft_numeric_floating_5significantdigits, ft_numeric_floating_fixedpoint1digits, ft_numeric_floating_fixedpoint2digits, ft_numeric_floating_fixedpoint3digits.

J.BL

PS: If someone is searching for a real - let me say - strange handling feature (aka Bug ;-) ) of columns of content plugins in Total commander, may be here is one: String values are sorted always as if they are formated on the left side of the column even they are formated to the right side of the column. If this handling is fixed, this Posting is obsolete.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

TC 6.52 will solve it like this: After the numeric floating point value, the plugin can return a string value of the number converted to string in the way the plugin developer wants. TC will then display that string, but use the numeric value for sorting or searching.

This will be both backwards and forwards compatible, older versions of TC will just convert the numeric value, and older plugins which do not set the string value will make TC use just the numeric value too (the string is set to 0x00 before calling the function).

Thanks to Lefteous who suggested this (if I remember correctly).
Author of Total Commander
https://www.ghisler.com
J.Bl
Member
Member
Posts: 116
Joined: 2005-01-23, 16:29 UTC

Post by *J.Bl »

Hello,
ghisler(Author) wrote:TC 6.52 will solve it like this: After the numeric floating point value, the plugin can return a string value of the number converted to string in the way the plugin developer wants. TC will then display that string, but use the numeric value for sorting or searching.
Thank you for your support.

Something about my - well working - currently used workaround: A fixed-point number with 3 decimal digits is shown in a "ft_string" formated column. For sorting capability it is fill up - up to 9 characters (for values 0-99999) with leading blanks.

J.BL
User avatar
tbeu
Power Member
Power Member
Posts: 1336
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Post by *tbeu »

It should be mentioned
  • that the optional trailing string is a wide string for ContentGetValueW and
  • what is the maximum string length.
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more
Post Reply