Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Listview callbacks
Topic Summary: nested functions for listview data extraction
Created On: 13-Oct-2008 21:53
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by David Jakad, on Tuesday, October 14, 2008 9:43 AM

Answer:
In general, the DBEs need to be global.

All the callbacks follow a pre-determined syntax, with only the "current" DBE passed in as a variable. So, if you want to have a dialog box where a user clicks a button, and information is extracted from the listView, the listView must be global, because the pre-determined syntax for the button callback is "void fnButtonClick(DBE xButton) {}". The only variable passed to the callback is the button DBE (which is worthless....EDIT: well, almost worthless... you can use setParent and make the listView the parent of the button; then within the callback, you can use getParent to get the parent of the button, i.e., the listView). There is no way to pass in another DBE, such as the listView.

The attached code shows a listView with some callbacks.

If is possible to declare the listView and the set(listSelect,listDeselect,listActivate) callbacks locally within some function, as long as you attach the callbacks to the list view within the same function. This works because these callbacks pass in the listView you want, i.e., these callbacks follow the syntax: "void fnListSelect(DBE xListView, int i)". But, of course, you won't be able to have any other callbacks interact with the listView, because now the listView is a local variable.
 13-Oct-2008 21:53
User is offline View Users Profile Print this message


Mark Williamson

Posts: 79
Joined: 12-Sep-2005

Hello All,

I have created a DB with only two DBE's, a list view and a FileName. The list view is being correctly populated on the basis of a user selection and the fileName DBE is no problem. I thought that was the hard work done but I have not been able to figure out how to extract the value of the single list view selection within a call back.
I simply want to create an external link from a module based upon the link view selection to a file specified by the fileName DBE. How hard can it be???

When attempting to create call back functions, the variables required are invariably out of scope?

Any pointers in the right direction would be much appreciated.

Thanks in advance

Mark

-------------------------

mark_williamson@synthesys.co.uk
http://www.synthesys.co.uk
----------------------------------------
Report this to a Moderator Report this to a Moderator
 13-Oct-2008 22:48
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Since callbacks routinely access DBE that are not part of the call parameter, the DBE declarations need to be global; as does often the DB declaration. Declare them at the top, use them at the bottom. Most of my scripts use a Dialog, and ALL of them are structured like this:
[] Normal global variable and constant declarations
[] DB and DBE declarations
[] Various functions
[] Dialog callbacks
[] Main create-dialog function, that creates the DB and DBEs

- Louie
Report this to a Moderator Report this to a Moderator
 13-Oct-2008 22:57
User is offline View Users Profile Print this message


David Jakad

Posts: 94
Joined: 20-Jul-2007

Answer Answer
In general, the DBEs need to be global.

All the callbacks follow a pre-determined syntax, with only the "current" DBE passed in as a variable. So, if you want to have a dialog box where a user clicks a button, and information is extracted from the listView, the listView must be global, because the pre-determined syntax for the button callback is "void fnButtonClick(DBE xButton) {}". The only variable passed to the callback is the button DBE (which is worthless....EDIT: well, almost worthless... you can use setParent and make the listView the parent of the button; then within the callback, you can use getParent to get the parent of the button, i.e., the listView). There is no way to pass in another DBE, such as the listView.

The attached code shows a listView with some callbacks.

If is possible to declare the listView and the set(listSelect,listDeselect,listActivate) callbacks locally within some function, as long as you attach the callbacks to the list view within the same function. This works because these callbacks pass in the listView you want, i.e., these callbacks follow the syntax: "void fnListSelect(DBE xListView, int i)". But, of course, you won't be able to have any other callbacks interact with the listView, because now the listView is a local variable.

Edited: 13-Oct-2008 at 23:20 by David Jakad
Report this to a Moderator Report this to a Moderator
 13-Oct-2008 23:17
User is offline View Users Profile Print this message


David Jakad

Posts: 94
Joined: 20-Jul-2007

Here is a similar sample, but with the listView declared locally within a function.

You will see this will run you into some issues. With a listView, you must add the columns after you realize the dialog box. But, with the listView declared locally, the only solution is to add the realize() and insertColumn() functions within the same function, because the listView is no longer global. If you need to add anything else to this dialog box, it's going to be difficult.

Global DBEs is the basic solution. However, I found that with larger, more-complex dialog boxes (50, 100, 150+ DBEs), it can get difficult to manage all the global variables and all the functions that depend on those global variables. My solution was to create a single global Skip List, declare the DBEs locally, but then "register" these DBEs into that one global Skip List. Then, you can create functions that extract the DBEs from the Skip List. This is essentially the same as declaring all the DBEs globally; however, now you can declare them locally, which allows you to make more-portable functions.
Report this to a Moderator Report this to a Moderator
 14-Oct-2008 09:59
User is offline View Users Profile Print this message


Mark Williamson

Posts: 79
Joined: 12-Sep-2005

Louie and David,

Thanks very much for your comprehensive and valued responses. With a fresh pair of eyes this morning and the benefit of your postings, I realised that I actually had all the constituent elements in place but not in the right order/sequence. The key was in the global declaration of the DB & DBE. Please find attached a snippet of the functioning dxl. It's not pretty but it works!

Thanks again

Mark

-------------------------

mark_williamson@synthesys.co.uk
http://www.synthesys.co.uk
----------------------------------------
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.