M Mostez Well-Known Member Licensed User Longtime User Jul 31, 2022 #1 I want to call this sub from inlice C code, this code (calldrawrect) did not work it is just for explanation. Something like, B4X: void calldrawrect{ B4R::Array* b; B4R::Object* o; char* c = (char*)b->data; c[0] = 0; c[1] = 0; c[2] = 20; c[3] = 20; o = b; B4RdrawRect(o); } B4X: void B4RdrawRect(B4R::Object* o){ B4R::Array* b = (B4R::Array*)B4R::Object::toPointer(o); char* c = (char*)b->data; int x1 = (c[0]); int y1 = (c[1]); int x2 = (c[2]); int y2 = (c[3]); int tmp; if (x1>x2) { tmp=x1; x1=x2; x2=tmp; } if (y1>y2) { tmp=y1; y1=y2; y2=tmp; } drawHLine(x1, y1, x2-x1); drawHLine(x1, y2, x2-x1); drawVLine(x1, y1, y2-y1); drawVLine(x2, y1, y2-y1+1); }
I want to call this sub from inlice C code, this code (calldrawrect) did not work it is just for explanation. Something like, B4X: void calldrawrect{ B4R::Array* b; B4R::Object* o; char* c = (char*)b->data; c[0] = 0; c[1] = 0; c[2] = 20; c[3] = 20; o = b; B4RdrawRect(o); } B4X: void B4RdrawRect(B4R::Object* o){ B4R::Array* b = (B4R::Array*)B4R::Object::toPointer(o); char* c = (char*)b->data; int x1 = (c[0]); int y1 = (c[1]); int x2 = (c[2]); int y2 = (c[3]); int tmp; if (x1>x2) { tmp=x1; x1=x2; x2=tmp; } if (y1>y2) { tmp=y1; y1=y2; y2=tmp; } drawHLine(x1, y1, x2-x1); drawHLine(x1, y2, x2-x1); drawVLine(x1, y1, y2-y1); drawVLine(x2, y1, y2-y1+1); }
Erel B4X founder Staff member Licensed User Longtime User Jul 31, 2022 #2 I don't understand the code in calldrawrect. It cannot work. Why work hard? Use global int variables. Upvote 0
I don't understand the code in calldrawrect. It cannot work. Why work hard? Use global int variables.
M Mostez Well-Known Member Licensed User Longtime User Jul 31, 2022 #3 the code in calldrawrect is for calling B4RdrawRect, Erel said: It cannot work Click to expand... it is just pseudocode, I want to create object and pass it to B4RdrawRect. Upvote 0
the code in calldrawrect is for calling B4RdrawRect, Erel said: It cannot work Click to expand... it is just pseudocode, I want to create object and pass it to B4RdrawRect.