Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Code Samples & Tips Share your recent discoveries and ideas with other users.

(advanced) Read Basic4ppc thread parameters

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-31-2009, 07:03 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default (advanced) Read Basic4ppc thread parameters

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:
Code:
(double)Thread.GetData(Thread.GetNamedDataSlot("fixX"))
(
double)Thread.GetData(Thread.GetNamedDataSlot("fixY"))
(
double)Thread.GetData(Thread.GetNamedDataSlot("scaleX"))
(
double)Thread.GetData(Thread.GetNamedDataSlot("scaleY"))
(bool)
Thread.GetData(Thread.GetNamedDataSlot("cPPC"))
(bool)
Thread.GetData(Thread.GetNamedDataSlot("optimized"))
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.basic4ppc.com/forum/beta-...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:
Code:
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
Note that this code requires Door library v1.2 or newer.
Reply With Quote
  #2 (permalink)  
Old 08-01-2009, 06:32 PM
Knows the basics
 
Join Date: Dec 2008
Posts: 77
Awards Showcase
Beta Tester 
Total Awards: 1
Default

This is Good... Thanks

I was resently wondering how to get some properties without using reflection.
Guess this is a start.

I noticed the Threading library has using DBasic.
Which would also be a way to get info from b4p.

But that's a different topic.

Thanks Again,
E
Reply With Quote
  #3 (permalink)  
Old 08-01-2009, 07:13 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

(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.
Reply With Quote
  #4 (permalink)  
Old 08-01-2009, 08:43 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

<even more super advanced>)
Quote:
I noticed the Threading library has using DBasic.
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>
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.

Last edited by agraham : 08-02-2009 at 08:35 AM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Thread NamedDataSlot type discrepancy agraham Beta Versions 6 05-01-2009 04:02 PM
RE:Remove a posted Thread wm.chatman Questions (Windows Mobile) 1 04-03-2009 04:40 AM
Thread and FormEx libraries with 6.42 agraham Beta Versions 9 08-27-2008 04:18 PM
Basic4ppc v6.30 comand line parameters (batch) Cableguy Questions (Windows Mobile) 2 06-21-2008 11:00 AM
Instert code in a thread of this forum pmu5757 Questions (Windows Mobile) 2 05-09-2008 05:25 PM


All times are GMT. The time now is 10:34 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0