Android Question ad hoc assignment of custom type


Active Member
Licensed User
Longtime User
I have a custom type that I would like to use in some const variables. I tried this:

Sub Process_Globals
    type sometype_t(a as int, b as int)

    dim const some_1 as sometype_t = assign(1, 2)
    dim const some_2 as sometype_t = assign(2, 3)
    dim const some_3 as sometype_t = assign(134, 235)
    dim const some_4 as sometype_t = assign(0, 55)
end sub

private sub assign(p1 as int, p2 as int) as sometype_t
    dim t as sometype_t
    t.a = p1
    t.b = p2
    return t
end sub

But I get an error "cannot find symbol".

Is there any way to assign values to custom types in line?

1. Never write code, other than declarations or simple assignments, in Process_Globals.
2. Don't waste your time with activities. Switch to B4XPages.
3. There is a built-in feature to create the sub that you are looking for (though your sub is also fine in this case):