B4J Question [BANano] Map Original & Map GetDefault Values Differences when value = 0?

Mashiane

Expert
Licensed User
Longtime User
Ola

I've been wondering why my validation has not been working whilst my form actually has values. The record is read as a map record. So for example, Femication Required Yes = 0, the rest the same methodology. My validation is global, it gets the map values, gets the default values and if a default value is blank, there is an error.

validation.png


On further scrutiny, if the original value is 0 for a key and you execute a getdefault on it, its returned as blank. I need to use .getdefault for my app to work. The assumption is that the value in a map can be anything and of unknown data type.

Reproduction

B4X:
Dim mymap As Map = CreateMap("itemname": "Badi Soap.", "femdays": 0, "femperiod": -1, "itemno": 28)
    For Each k As String In mymap.Keys
        Log($"Key: ${k}"$)
        Dim v As String = mymap.Get(k)
        Dim vd As String = mymap.GetDefault(k, "")
        Log($"Original: ${v}"$)
        Log($"Default: ${vd}"$)
        Log("****")
    Next

Result

B4X:
app.js:7 Key: itemname
app.js:7 Original: Badi Soap.
app.js:7 Default: Badi Soap.
app.js:7 ****
app.js:7 Key: femdays
app.js:7 Original: 0
app.js:7 Default:
app.js:7 ****
app.js:7 Key: femperiod
app.js:7 Original: -1
app.js:7 Default: -1
app.js:7 ****
app.js:7 Key: itemno
app.js:7 Original: 28
app.js:7 Default: 28
app.js:7 ****

So as it is the value of "femdays" with .getdefault is blank. Is there a way around this?

Ta!
 

Attachments

  • MapNumerics.zip
    1.7 KB · Views: 166

alwaysbusy

Expert
Licensed User
Longtime User
Will be fixed in the next version and will return the following. Please check if this is the desired result:

B4X:
Key: itemname
app.js:36 Original: Badi Soap.
app.js:38 Default: Badi Soap.
app.js:40 ****
app.js:30 Key: femdays
app.js:36 Original: 0
app.js:38 Default: 0
app.js:40 ****
app.js:30 Key: femperiod
app.js:36 Original: -1
app.js:38 Default: -1
app.js:40 ****
app.js:30 Key: itemno
app.js:36 Original: 28
app.js:38 Default: 28
app.js:40 ****

Alwaysbusy
 
Upvote 0
Top