Externals

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
Externals that are hungry for data. What would be the better way to transfer big amounts of data to an external JAVA code? Should you use array? temporary shared files? We're talking maybe 200k - 2MB thereabout.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,135
Maybe via a Databuffer, maybe as a String. Depends on how you get/read the data in the first place.
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
Okay, a databuffer would feel more effiicient to handle integers with, do you have any example how the JAVA side would look when you use databuffer? Can you use that bothways?
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,135
Simple, create a simple project with handling a databuffer, compile and then look at the translated Java code.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,135
Here is an example:

Code:
Strict

Import brl.databuffer
Import mojo

Class myApp Extends App
    '------------------------------------------------------------
    Method CreateBuffer:DataBuffer(len:Int)
        Local retbuf:= New DataBuffer(len)
        Return retbuf
    End
    '------------------------------------------------------------
    Method SetBuffer:Void(db:DataBuffer, index:Int, value:Int)
        db.PokeInt(index, value)
    End
    '------------------------------------------------------------
    Method OnCreate:Int()
        Local myDB:DataBuffer = CreateBuffer(1024)
        SetBuffer(myDB, 1, 1000)
        Return 0
    End
End

Function Main:Int()
    New myApp
    Return 0
End

Which translates to


Java:
class c_myApp extends c_App{
    public final c_myApp m_myApp_new(){
        super.m_App_new();
        return this;
    }
    public final c_DataBuffer p_CreateBuffer(int t_len){
        c_DataBuffer t_retbuf=(new c_DataBuffer()).m_DataBuffer_new(t_len,false);
        return t_retbuf;
    }
    public final void p_SetBuffer(c_DataBuffer t_db,int t_index,int t_value){
        t_db.PokeInt(t_index,t_value);
    }
    public final int p_OnCreate(){
        c_DataBuffer t_myDB=p_CreateBuffer(1024);
        p_SetBuffer(t_myDB,1,1000);
        return 0;
    }
}
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
Many thanks for the help and valueable information!
 
Top Bottom