Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Mon Nov 20, 2017 2:20 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Object Allocation
PostPosted: Thu Feb 12, 2009 12:52 pm 
Offline

Joined: Wed Feb 11, 2009 9:32 am
Posts: 34
Based on this thread
viewtopic.php?f=6&t=3510&hilit=possibly+empty

am I write in deducing that objects can not be allocated by other objects? In order to create an instance of an object it has to be dragged into the drawing area?

I have an object that is parsing data from a network stream. Depending on some values the data could be very different and I would like to delegate other objects to further parse the data. Is it possible for me to create an object dynamically?

My parse class is called NetworkParser which parses data from a network packet. Now suppose I have another class called subParser which is to handle retrieving some of the data in the data array. Can I do something similar to the following?

dim subParser as MyParser
dim differentSubParser as MyOtherParser

func parseData(data[] as byte)
'parse some data

If (someValueRead == 0) then
subParser.parseData(data,offset)
endif
if (anotherValueRead == 2) then
differentSubParser.parseData(data,offset)
endif
endfunc

If not then I would need 23 different sub parsers the user would have to add to the screen.


Top
 Profile  
 
 Post subject: Re: Object Allocation
PostPosted: Thu Feb 12, 2009 1:32 pm 
Offline
User avatar

Joined: Thu Mar 02, 2006 2:12 pm
Posts: 487
Location: Salt Lake City, Utah
Quote:
am I write in deducing that objects can not be allocated by other objects? In order to create an instance of an object it has to be dragged into the drawing area?

Yes

Quote:
Is it possible for me to create an object dynamically?

No, please see this FAQ for more information on this topic and alternative solutions.
viewtopic.php?f=4&t=110

Code:
dim subParser as MyParser
dim differentSubParser as MyOtherParser

This code does not create objects, just references (like a pointer) to instance of objects.

_________________
Ron L.

http://www.beijerelectronicsinc.com/


Top
 Profile  
 
 Post subject: Re: Object Allocation
PostPosted: Thu Feb 12, 2009 1:38 pm 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Quote:
If not then I would need 23 different sub parsers the user would have to add to the screen.


This last statement may not be strictly true, depending on what you are doing.

First of all, are you writing a Qlarity application? Or a framework for which your users/customers will be creating their own applications?

If you are simply writing a Qlarity application, you can easily enough create your twenty three sub parsers and do what you want with them.

If you are writing a framework, you can still create the twenty three sub parsers and place them in a library entry where they will automatically be created when they create an instance of your main parser object.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject: Re: Object Allocation
PostPosted: Thu Feb 12, 2009 1:53 pm 
Offline

Joined: Wed Feb 11, 2009 9:32 am
Posts: 34
Thank you I'm writing a framework. I'll look at library creation and how that works, I was putting it off to see if what we are doing can be accomplished. If they get created automagically that would be awesome.

Thanks


Top
 Profile  
 
 Post subject: Re: Object Allocation
PostPosted: Mon Feb 16, 2009 8:04 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
To get you started in this direction, I would suggest you go to Advanced Code in your Object Tree. (Advanced Code is only visible in Code View, and only if you have checked "Show advanced code sections..." in Tools->Settings->Editor.

In there, you can create an object via code with the following syntax

Code:
declare sp1 as SubParserType1
enddec


This will create an object called sp1 of template type SubParser1

You can repeat this as many times as needed.

When you are to the point of creating your library entry(ies), you can cut and paste the declares into that library entry.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 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