Forum Discussion

adamXpeter's avatar
adamXpeter
New Contributor
21 days ago
Solved

Storages.INI GetOption with null default value does not work

Dear SmartBear,

GetOption with default null value does not work. If I give an empty string as default value it works. Why?

See the screenshot above, GetOption(_opcionev, null) returns null, while using an empty string or "XXX" it returns the correct value, "John", from the INI file.

Haven't tested the other ways with null default value.

Is this a correct operation?

Best regards,

Peter

3 Replies

    • adamXpeter's avatar
      adamXpeter
      New Contributor

      Thanks!

      A bit disagree here, as Variants can hold Object types, which are reference types, and initialized as null:

      • The initial values for object type variables are always empty (null in JavaScript, JScript, C#Script and C++Script, None in Python, Nothing in VBScript and nil in DelphiScript).

      Variables of the Object Type | TestComplete Documentation

      So I have to fight the "empty string is not nothing" war again, check the existence of the value in the INI file, and set null by my code.

      • rraghvani's avatar
        rraghvani
        Icon for Champion Level 3 rankChampion Level 3

        Here's an example,

        In the INI file, Type has an empty value. When we call GetOptions("Type", null), it will return a "null object" 

        If "Type=HelloWorld", and we call GetOptions("Type", null), it will still return a "null object". We need to specify the default value type as either Integer, Double/Real, String etc. JavaScript is inherently a dynamically typed language meaning variables can hold values of any type without strict enforcement