B4R Question Read data from array by array name

Discussion in 'B4R Questions' started by Mostez, Jun 23, 2019.

  1. Mostez

    Mostez Active Member

    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)

    Code:
    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
    Code:
    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()]);
    }
     
    Johan Schoeman likes this.
  2. Erel

    Erel Administrator Staff Member Licensed User

    Your code looks fine. Passing arrays to inline C is possible but will make things more complicated.
     
  3. Mostez

    Mostez Active Member

    Thanks
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice