Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Sat Nov 18, 2017 8:52 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Objects without types
PostPosted: Thu Aug 23, 2007 10:07 am 
Offline
User avatar

Joined: Sat Aug 12, 2006 6:33 pm
Posts: 57
Location: Richmond, VA
I have some objects that do not have types, yet QF does not complain about this. (I inherited this project so I don't know much more than that.)



How can I tell what object type they are really tied to? Should I correct this? If so, how?



In a related topic, how can I create objects that do not have types?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 10:19 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Here is where some sample code could be useful.



I am not quite sure what you mean.



EVERY object in Qlarity has a type of some sort.



In certain situations, object reference (objref) variables may exist which do not have an explicit type. These are usually called generic objrefs. A generic objref can refer (point in C parlance) to any object in your project, regardless of its type. It can also refer to the special "default" object which is the root container which hosts all other objects. It can finally refer to "empty" which is not an object at all and used if an objref is not referring to anything.



Most API functions work on generic objrefs and do not care about their type. Enable, for instance, doesn't care if it is enabling a button or a screen.



The drawback go generic objrefs is that you cannot directly operate on any of their methods or properties. For example:

Code:
dim obj1 as objref

init obj1 := Button_1

obj1.value = "Click Me"




Will not work. This is because the compiler sees that obj1 is a generic object reference and has no idea whether that object has a property called "value." (In this example it is easy to see that obj1 refers to a Button object, but many times in code that would be impossible for the compiler to know).



In these situations, you want what is called a typed object reference or typed objref.

[/code]

dim btn1 as objref ButtonV2

init btn1 := Button_1

btn1.value = "Click Me"[/code]



This example works because the compiler knows that btn1 will be a ButtonV2 object and the compiler knows how to access the value property of a buttonv2 object. You could not assign btn1 to refer to a ScreenV2 object. The compiler would not allow it.



Occasionally, you have an issue like this:



Code:

func SetTheFont(probablyAButton as objref)

    'I need to set the font property of "probablyAButton" refers to a button

    dim btn1 as objref ButtonV2

    Check Error

        'Try to convert to a buttonV2

        Val(btn1, str(probablyAButton))

    on error

        _ClearException()

        Transmit (com1, str(probablyAButton) + " wasn't really a button", false)

    enderr



    btn1.font = default_bdf

endfunc





You need to convert the generic objref to a typed objref. This can be done with the Val and Str functions in the previous example.[/code]

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 10:39 am 
Offline
User avatar

Joined: Sat Aug 12, 2006 6:33 pm
Posts: 57
Location: Richmond, VA
Here is the pertinent parts of the code:



Define Object type LocaleController



...



Define Object type BaseLocaleController extends LocaleController



...



Define Object type VacuumLocaleController extends BaseLocaleController



dim locale as VacuumLocaleController



...



locale := _locale



and this is the only location in the entire workspace where _locale shows up in text form. In the object hierarchy, _locale is an object. The icon is orange with a white X on it. If I view the Instance Fundamentals on it, the name _locale correctly appears, but the type is blank. Why is it blank?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 10:53 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
That means that _local is of a type that Qlarity Foundry doesn't know about.



Qlarity Foundry does not monitor the Advanced Code section of its workspace, nor text files imported with either #include or include for new object types.



I suspect that _locale is of a type that is defined in your included text file. In that case, the drop list listing it's type will be blank. However if you hover the mouse over it in the object tree, it might tell you its type via a tool tip.



In general, I try to manually declare objects that fall in this category in the Advanced Code section (where said objects will not appear in the Object Tree). However, this is starting to get into very advanced development techniques for Qlarity.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 11:03 am 
Offline
User avatar

Joined: Sat Aug 12, 2006 6:33 pm
Posts: 57
Location: Richmond, VA
OK, this is good information.



Note: The unknown object type occurs the workspace before moving code to the Advanced Code section.



If I hover the mouse over the object in the tree it does indeed show the correct object type (VacuumLocaleController), but I cannot figure out how it was defined. I've searched the workspace through and nowhere is there a dim _locale as VacuumLocaleController.



How can this object have a type -- a correct type at that -- but it is not explicitly called out in code nor in the popup menu in the heirahy?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 11:38 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Search the saved (.qly) file. Object declarations are normally managed by Qlarity Foundry and you cannot see them directly in code.



Basically, if you had an object with this code:

Code:

init parent := default

init enabled := true





The .qly file might have

Code:

declare ThisObj as SomeObjType

level 53212

init parent := default

init enabled := true

enddec





Qlarity Foundry strips out the declare and level statements and just presents you with the core code.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 23, 2007 12:40 pm 
Offline
User avatar

Joined: Sat Aug 12, 2006 6:33 pm
Posts: 57
Location: Richmond, VA
Ha! That was it. It was defined in the .qly. Once I made the change everything works agin. Even the Interpreter Stack Blown failure (in other posting) is gone now.



Thank you!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 7 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group