Jump to content
Developer Wiki and Function Reference Links ×

Strings for Boolean values?


Stefan Bender

Recommended Posts

Dear developers,

 

is there an official SDK way to get the strings for the Boolean values "True" and "False"? They might be needed for tables or for displaying them in other contexts. What is the VW rule for these strings? Are they localized, uppercase, lowercase? I think it would be helpful to have some sort of consistent behavior and /or an SDK call to get the strings. I'm asking because I just got a bug report that is related to this (a plug-in of ours is trying to import values from a text file into a VW record field and it turned out that we had not specified how boolean values need to be spelled so the plug-in identifies the strings as "true" or "false").

 

Thanks,

Link to comment

I'm fairly sure the SDK doesn't have any built-in conversions for boolean strings. As a check, though, you can convert the string to uppercase and compare against "TRUE" and the localized true converted to upper case. Then return the localized value for true or false accordingly.

 

When you write to the field, use SetParamBool() to ensure the correct format. I believe that regular record fields are localized but PIO fields are not. I could be wrong, though.

 

Link to comment

Andy Dunning shared the following functions.  I hope he won't mind my sharing them here.

 


    FUNCTION Boo2Str(boo :BOOLEAN) :STRING;
        {Converts a boolean to a string.}
    BEGIN
        IF boo 
            THEN Boo2Str := 'True' 
            ELSE Boo2Str := 'False';
    END; {FUNCTION Boo2Str}
    

 


{==============================================================}

 

 

 

    FUNCTION TestBooleanStr(boo :STRING) :BOOLEAN;

    VAR
        str : STRING;
    
    {---------- NVW Function to Replace UprString ----------}
        FUNCTION UCase(str :STRING) :STRING;

        BEGIN
            UprString(str);
            UCase := str;
        END;
    {-------------------------------------------------------}
    
    BEGIN
        GetVWRString(str,'IP Resources/Strings/11000 *','3');

        TestBooleanStr := (UCase(boo) = 'TRUE') | (UCase(boo) = UCase(str));
    END; {FUNCTION TestBooleanStr}

 

The call to "GetVWRString(str,'IP Resources/Strings/11000 *','3');" is the arcane magic that I did not know about.

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...