As of version 6.80 Basic4ppc stores several values in the main thread slots.
This allows external libraries to read these parameters and act accordingly.
The C# code is:
scaleX / scaleY - have the same value as Basic4ppc keywords ScreenScaleX / ScreenScaleY.
fixX / fixY - used in AutoScale compilation. See this thread for more information: http://www.b4x.com/forum/beta-versions/4207-autoscale-compilation-mode-external-libraries.html
cPPC - same as Basic4ppc cPPC (true when running on the device and false on the desktop).
optimized - True for optimized compiled applications and false otherwise.
It is also possible to read these values from Basic4ppc with the door library.
Basic4ppc code:
B4X:
Sub ReadValueFromThread (property)
AddObject("obj1", "Object")
AddObject("obj2", "Object")
AddObject("objArr", "ObjectArray")
obj1.New1(True)
obj2.New1(False)
obj1.CreateNew("System.Threading.Thread" & obj1.System_Mscorlib)
obj2.Value = obj1.RunMethod2("GetNamedDataSlot", property, "System.String")
objArr.New1(1)
objArr.SetObject(0, obj2.Value)
ret = obj1.RunMethod4("GetData", objArr.Value)
obj1.Dispose
obj2.Dispose
objArr.Dispose
Return ret
End Sub
(super advanced)
There are two additional objects in this list:
Thread.GetData(Thread.GetNamedDataSlot("b4p"));
Thread.GetData(Thread.GetNamedDataSlot("CRunner"));
b4p - returns for optimized compiled applications a reference for the main object.
CRunner - returns for IDE or nonoptimized compiled applications a reference to the main IDE.
The reason for this is to reference the delegate types declared in Basic4ppc at compile time. The delegates types are required to call optimised compiled Subs from a library. This is needed for Threading to run on the device as in the Compact Framework Reflection does not let you instatiate delegate types at runtime because it lacks the CreateDelegate method.
A compile time reference to Dbasic is normally not needed to use Reflection on the Crunner or b4p objects on the device (or desktop)as the Compact Framework fully supports Reflection on properties, fields and methods (as far as I've needed it so far!). My Debug library relies entirely on Reflection to work its' magic. </even more super advanced>