B4R Question Read data from array by array name

Mostez

Active Member
Licensed User
Hello,
I have 5 font arrays and I use 5 procedures calls in C++ region to read character set of needed font, is it possible to use one procedure and pass array name or reference instead?

i.e. RunNative(ArrayName, Index)

B4X:
Private Sub GetFontByte(FontType As Byte, Index As UInt) As Byte
    'TODO(3) Add #C font array:
    Select FontType
        Case FontDots5x8
            Return RunNative("get5x8data", Index)
        Case FontDots8x8
            Return RunNative("get8x8data", Index)
        Case FontArial8x16
            Return RunNative("get8x16data", Index)
        Case FontDigital16x16
            Return RunNative("get16x16data", Index)
        Case FontDigital16x24
            Return RunNative("get16x24data", Index)
    End Select
End Sub
B4X:
B4R::Object beo1;
B4R::Object* get5x8data(B4R::Object* o) {
   return beo1.wrapNumber(FontDots5x8Array[o->toLong()]);
}

B4R::Object beo2;
B4R::Object* get8x8data(B4R::Object* o) {
   return beo2.wrapNumber(FontDots8x8Array[o->toLong()]);
}


B4R::Object beo3;
B4R::Object* get8x16data(B4R::Object* o) {
 return beo3.wrapNumber(FontArial8x16Array[o->toLong()]);
}

B4R::Object beo4;
B4R::Object* get16x16data(B4R::Object* o) {
 return beo4.wrapNumber(FontDigital16x16Array[o->toLong()]);
}

B4R::Object beo5;
B4R::Object* get16x24data(B4R::Object* o) {
 return beo5.wrapNumber(FontDigital16x24Array[o->toLong()]);
}
 
Top