[WDX] Placeholder string for delayed fields in ContentGetValue

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

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

[WDX] Placeholder string for delayed fields in ContentGetValue

Post by *Dalai »

Hi to everyone.

The WDX (and WFX content) plugin documentation says
ft_delayed, ft_ondemand: You may return a zero-terminated string as in ft_string, which will be shown until the actual value has been extracted.
Stripped down code (partly pseudo code):

Code: Select all

function ContentGetValueW(const FileName: PChar; FieldIndex, UnitIndex: integer; FieldValue: PByte;
                          MaxLen, Flags: integer): integer; stdcall;
const
  DELAYED_PLACEHOLDER : string = '...';
begin
[...]
    if IsFlagSet(flags, CONTENT_DELAYIFSLOW) then begin
        { place information in thread }
        [...]
        lstrcpyn(PChar(FieldValue), PChar(DELAYED_PLACEHOLDER), LMaxChars);
        Result:= ft_Delayed;
    end else begin
        if ThreadFinished then begin
            PInteger(FieldValue)^:= ThreadResult;
            Result:= ft_Numeric_32;
        end else begin
            { 1 }
            lstrcpyn(PChar(FieldValue), PChar(DELAYED_PLACEHOLDER), LMaxChars);
            Result:= ft_String;
            { 1 }
        end;
    end;
    [...]
end;
It does work when I set the return value to ft_String in the part marked with { 1 }. Is this how it's supposed to work, i.e. change the field type to ft_String instead of the actual field type, and copy the placeholder string again? If so, the documentation doesn't state this (clearly enough).

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [WDX] Placeholder string for delayed fields in ContentGetValue

Post by *ghisler(Author) »

If CONTENT_DELAYIFSLOW isn't set, then TC expects the actual field value. You can change the type of field returned via the return type, so if you want to return a string, you need to return ft_string.
Author of Total Commander
https://www.ghisler.com
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: [WDX] Placeholder string for delayed fields in ContentGetValue

Post by *Dalai »

OK, so I have guessed correctly after hours and hours of trial and error. Guessing is not what I need or want to do. As I said: the documentation needs to be improved on this - among several other things I've come across over the years. Suggestion: Add the two sentences you wrote here to the ContentGetValue's documentation.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [WDX] Placeholder string for delayed fields in ContentGetValue

Post by *ghisler(Author) »

Actually it is documented:
Total Commander now accepts that ContentGetValue returns a different data type than ContentGetSupportedField for the same field, e.g. a string "no value" instead of a numeric field. Note that older versions of Total Commander crashed in the search function in this case, so if you want to do this, you MUST check that the plugin version is reported as >=1.3 (hi=1, low>=3 or hi>=2).
Author of Total Commander
https://www.ghisler.com
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: [WDX] Placeholder string for delayed fields in ContentGetValue

Post by *Dalai »

Well, that's below the ft_fulltext paragraph, so I didn't pay attention to it because I thought it's related to that. Maybe add a line like "Return value" in bold before that paragraph?

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Post Reply